Skip to content

Using APIs

Each resource you describe will be available using RESTful standard patterns. Using part of the example from Creating APIS, the following examples show how to access the data in your API.

Provided the following resource description for post:

post:
slug: string
title: string
body: string
published: datetime
categories: << category
tags: << tag

RESTful standard CRUD methods for each resource:

GET /post
GET /post/:id:
POST /post
PUT /post/:id:
PATCH /post/:id:
DELETE /post/:id:

Each resource is also able to be queried with standard HTTP URL query fields:

GET /post?title="Attaianble APIS"
GET /post?tag="resources"&tag="apis"

Each resource can be sorted using familiar :ASC and :DESC suffixes for fields. It’s possible to sort the responses using the sort query in the URL:

GET /post?sort=title:DESC
GET /post?sort=slug:ASC
GET /post?sort=createdat:DESC

You can control the size and the index of the data responses:

GET /post?size=100
GET /post?size=50&index=4

Each of the resources associations can be retrieved with a standard path pattern:

GET /post/42/tags
GET /post/42/categories

Each Attainable API has it’s resources available through automatically generated OpenAPI documentation. You can reach the documentation by using the /docs path for each API.