Overview

Introduction to API

What is an API?

It means “Application Programming Interface”. Through APIs, applications can communicate with each other without user intervention. They work by communicating different codes, defining specific behaviors of a given object in an interface.

In general, an API consists of a series of functions accessible only programmatically.

APIs RESTFul

Our APIs are RESTFul (Representational State Transfer), meaning that they don’t store state; therefore, each call is fully independent from other calls. A Rest API has advantages over the methodologies defined by the HTTP protocol, such as the use of verbs already specified for representing actions to be carried out in the resources. Examples: use of the GET method for search of information, POST method for creating new resources, DELETE for excluding, etc.

An API is accessible through an URI comprising the following elements:

https://[environment]/[product]/[version]/[resources]/[parameters]

Due to the encryption needed for the safe transfer of data, the protocol used is always “https”. The other elements are described in detail below:

product: represents the ANBIMA product exposed through the API in question

version: represents the version of the API in question

resources: identify the information expected to be obtained when a certain service is requested (within the scope of this API, it refers to the packages and items that contain information of indices).

API Response Content Format

By default, all responses are in JSON format (JavaScript Object Notation) – an open standard format that considers human-readable text to transmit data, consisting of “attribute/value” pairs. For more information about this format, access the following link: https://www.json.org/json-pt.html 

However, for some APIs, it is possible to send a header to obtain the XML format.

Technology and Standards

REST

Architecture for providing resources through distributed systems, commonly used with HTTP protocol. For more details, access: https://www.w3.org/2001/sw/wiki/REST.

JSON

Standard for describing data used to exchange information between systems. It is simpler and lighter than some other market alternatives, such as XML. For more details, access: https://www.w3.org/TR/html-json-forms/#introduction.

HTTP 1.1

Highly-used standard transfer protocol. For more details, access: http://www.w3.org/Protocols/rfc2616/rfc2616.html or http://www.ietf.org/rfc/rfc2616.txt.

UTF-8

A set of standard characters for communication among distributed systems. For more details, access: https://www.w3.org/International/questions/qa-choosing-encodings.

ISO-8601

Standard format specific for date and time data.

Standard: YYYY-MM-DDThh:mm:ss.sTZD
Example: 2013-06-28T08:54:00.000-03:00

Endpoints

There are only two endpoints for accessing our APIs, namely, Production and Sandbox. While developing your application, always use the Sandbox endpoint, and only change to Production when the entire integration of your application is concluded. The ANBIMA’s endpoints to access the environments are as follows:

Production URLSandbox URL
https://api.anbima.com.br https://api-sandbox.anbima.com.br

Important note: Don’t forget to include the API version before the resource. For example: /api/v1, for version 1 of the API.

HTTP Status Codes

Status CodeDescription
1xxInformative – Not used for APIs
2xxSuccess
3xxRedirecting
4xxClient Error
5xxServer Error

Main variations of Status Code 2xx:

Status CodeDescription
200Ok
201Created
202Accepted
204No Content

Main variations of Status Code 4xx:

Código de StatusDescrição
400Bad Request
401Unauthorized
403Forbidden
404Not Found
405Method not Allowed
412Precondition Failed
413Request Entity Too large
415Unsupported Media Type
422Unprocessable Entity
429Too many requests

Main variations of Status Code 5xx:

Código de StatusDescrição
500Internal Server Error
502Bad Gateway
504Gateway Timeout

Localization Standards

Field and Region Format Data:

Calendar:Gregorian Calendar
Country:Brazil
Currency:Real
First day of the week:Sunday
Date format:YYYY-MM-DD (ex,.: 2021-06-14)
Thousand separator:Dot (ex.: 1.000)
Decimal separator:Comma (ex.: 0,57)