Method defining routes to methods: good practices

Method defining routes to methods: good practices

Summary

Definition of routes orpathsmust be consistent with the resources or entities to which the method refers.

Certain good practices for considering in defining routes.



A review

Before proceeding, let's look at what parts of an endpoint or url. For example:
  1. "api" is the API query subdomain.
  2. "company.com" is the domain of your account.
  3. "Daily indicators" is the name of the API. Remember that the API name would be the item you define when creating the API.
  4. "v1" is the API version. Review the article on versions of APIs.
  5. "dolar" is the name of the API method.
  6. ".json" is the format of consultation to the method. Review the article on output formats.
  7. What follows the question mark "?" are the parameters to be sent, such as auth_key or others required by the method.

Definition of language

Define a language to use for your APIs and methods. We recommend using English if it is your primary language, but you can also use English. What is relevant in this case is to be consistent, the same language should always be used for APIs, methods, attributes, dictionaries, etc.

Method route

When creating a method, you should define your route.



  1. Use plural nouns, not verbs.
  2. Avoid using singular nouns.
  3. Use the same routes for different types of requests.
  4. Do not use accents, spaces or special characters in the URL.
  5. If you want to separate words use the average guide.

Correct examples

Get list of documents in .json format:
  1. Get https://api.empresa.com/api/v1/documents.json

Obtain documents by identifier in .json format:
  1. Get https://api.empresa.com/api/v1/documents/123.json

Create documents
  1. Post https://api.empresa.com/api/v1/documents.json

Incorrect examples

Singular nouns are not recommended:
  1. GET https://api.empresa.com/api/v1/documents
  2. GET https://api.empresa.com/api/v1/document/123.json
Verbs in the URL
  1. POST https://ejemplo.cl/api/v1/application/create

Parameters on the route

If required, you can add the data view parameters on the method path.

By default, the method inherits the parameters of its associated view. For example:
  1. http://api.junar.com/accounts/v1/users.json?auth_key=XXXXX&id=16329928

But it is also possible to add a parmeter on the method path. To do this, you must enter the route to the method on behalf of the key parameter.
For example:
  1. /users/{id}
In this case, the API consultation would have the following structure:
  1. http://api.junar.com/accounts/v1/users/123.json?auth_key=XXXXX

    • Related Articles

    • Try a method

      Summary The developer portal allows you to test reading methods (GETs) on the same portal. Test method Enter an API in the APIs Catalog on the portal's homepage. Then select a method and click on the buttonTest method. Select the implementation which ...
    • How to set up multi-environment in data views

      Summary The platform makes it possible to configure multiple environments for APIs methods. Multi-environment is configured at the data view level. Different data sources that correspond to each environment can be selected in the data view. For ...
    • APIs catalog and documentation

      Summary Once you have accessed the developer portal with your credentials, you can access the APIs catalog and its documentation. APIs Catalogue In the APIs Catalog you could learn about available APIs and access their documentation. API ...
    • Data sources from SOAP/xml web services

      Summary The SOAP/XML web services connector offers all the necessary capabilities to connect to these types of sources. This option allows collecting data from SOAP/XML web services or configuring writing actions, for then creating data views and ...
    • Audit API

      Summary The Audit API allows you to consult audit records in detail of applications received and responses submitted from APIs methods. Through this API you can learn the details of each of the requests made to your APIs and the responses submitted. ...