GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||
GeezerVison is showing www.mediawiki.org — Service-template-node/APIDesign - MediaWiki
API DesignBefore you start coding your service, you need to think hard about your API's design, especially for a public service exposing its API. Below are a couple of practices you should follow. StatelessnessRESTful API services should be stateless, since they are conceptually modeled around resources (as opposed to systems). Accordingly, your service should take actions depending on assumptions about the caller or the current state of the service's process (e.g. that the user is logged in, that they are allowed to modify a resource, etc.) VersioningYou should always version all of your API. Always. Period. Applications depend on its stability and invariance. It is tolerable to add endpoints to an API version, but removing or modifying existing ones is not an option. Thus, versioning provides an easy way for you to improve upon the API while avoiding third-party application breakage. The template enforces this practice by requiring all of your route files specify the API version. Hierarchical URI LayoutUse a hierarchical URI layout that is intuitive and makes sense. Grouping endpoints under a common URI prefix allows both you and the future API consumer to reason about the API. As an example, consider RESTBase's API layout: /{domain}
-- /v1
|- /page
| |- /title
| |- /html
| |- /data-parsoid
| -- /revision
-- /transform
|- /html/to/wikitext
|- /wikitext/to/html
-- /html/to/html
The API is grouped in two sections - HTTP VerbsThere are many HTTP verbs you can use and expose in your API. Use them appropriately. Especially, do not allow GET requests to modify any type of content. DocumentationDocument your API meticulously, and keep it up to date with the code. Remember that API's are meant to be consumed by external applications, whose developers most often do not know the internal workings of your stack. A good starting point is to look into Swagger, a specification for API declaration and documentation from which nice, demo-able documentation such as this can be automatically generated. See AlsoThe above is just a short list of things you should think about when designing your API. Here are some resources you might find useful at this step: | ||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |