BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

PayPal’s API Style Guide and Patterns

| by Abel Avram Follow 4 Followers on Sep 22, 2017. Estimated reading time: 1 minute | This item in chinese |

PayPal has created their platform as services connected to each other through RESTful APIs. They have developed guidelines and design patterns for creating and using these APIs, making them publicly available for other developers to get inspiration for their own projects.

PayPal has come up with API design guidelines over years of developing and evolving APIs that serve their platform. The guide has the following principles at its foundation:

  • Loose Coupling - Services and consumers must be loosely coupled from each other.
  • Encapsulation - A domain service can access data and functionality it does not own through other service contracts only.
  • Stability - Service contracts must be stable.
  • Reusable - Services must be developed to be reusable across multiple contexts and by multiple consumers.
  • Contract-based - Functionality and data must only be exposed through standardized service contracts.
  • Consistency - Services must follow a common set of rules, interaction styles, vocabulary and shared types.
  • Ease Of Use - Services must be easy to use and compose in consumers (and applications).
  • Externalizable – A service must be designed so that the functionality it provides is easily externalizable.

Business capabilities are exposed as resources – any information that can have a name. A resource is to be provided by only one service, avoiding duplication. The CRUD operations are permitted on resources, implemented by the following HTTP verbs:

  • GET - To retrieve a resource.
  • POST - To create a resource, or to execute a complex operation on a resource.
  • PUT - To update a resource.
  • DELETE - To delete a resource.
  • PATCH - To perform a partial update to a resource.

The HTTP requests and responses transmit data using the JSON Data Interchange Format based on a JSON Schema. Both JSON primitive – string, number, enumeration, array, null - and common types are supported. The latter include address, money, date, time, country, phone number, and others.

The API guide includes HATEOAS use cases with codes samples exemplifying how to use hyperlinks following the REST methodology. There are also guidelines on using HTTP Headers (standard and custom) and status codes, including mapping between HTTP methods and status codes, naming conventions for URIs, query parameters, resources, error handling, versioning and deprecation. PayPal has also made public another document, API Design Patterns And Use Cases, with patterns and code samples for using APIs.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT