click here and meet our API plans

This API provides access for products.

Authentication

All requests should contain the header field X-Cosmos-Token with their token to access API with their token access to API will be available below when you are logged in.


API modeling

All services provided through the API using REST technology (Representational State Transfer), an architecture for the provision of resources through distributed systems, commonly used over HTTP.
HTTP 1.1
The standard protocol for communication with the APIs is HTTP version 1.1. For more information about this protocol, see: http://www.w3.org/Protocols/rfc2616/rfc2616.html http://www.ietf.org/rfc/rfc2616.txt
UTF-8
The charset standard for calls to APIs is UTF-8. For more information on this coding, see: https://tools.ietf.org/html/rfc3629
JSON
JSON (JavaScript Object Notation) is a standard for data description for interchange between systems and is simpler and lighter than XML.

Endpoint

The endpoint to access the API is: https://api.cosmos.bluesoft.io

Services

The services bellow can be used to query the Cosmos general database:

/gtins/{code}
Retrieves product details via the GTIN / EAN informed.
/gpcs/{code}
Retrieve GPC details and products linked to it, through the informed code.
/ncms/{code}/products
Retrieve NCM details and products linked to it, through the informed code.
/products?query={description or EAN}
Retrieve list of paginated products by description or EAN.
In case of a retailer user, it is possible to use the following services to query their own products database:

/retailers/gtins/{code}
Retrieves retailer product details via the GTIN / EAN informed.
/retailers/gpcs/{code}
Retrieve GPC details and products linked to it in the retailer's database, through the informed code.
/retailers/ncms/{code}
Retrieve NCM details and products linked to it in the retailer's database, through the informed code.
/retailers/products?query={description OR EAN}
Retrieve a list of paginated products from the retailers database by description or EAN.

Success Code List

The API uses the following HTTP codes to indicate common success returns:

Error Code List

The API uses the following HTTP codes to indicate common mistakes:

Policy Rules

Access to Cosmos API services are regulated by policy roles. These rules define the amount of requests that can be performed for each service. Whenever the call limit is exceeded, the request is answered with the HTTP 429 status accompanied by a message stating the exceeded amount.

Examples

In the examples below, we give details of a product GTIN 7891910000197.

      require 'net/http'
      uri = URI.parse('https://api.cosmos.bluesoft.io/gtins/7891910000197.json')
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true
      request = Net::HTTP::Get.new(uri.request_uri)
      request['User-Agent'] = 'SUBSTITUIR PELO USER AGENT INFORMADO LOGO ABAIXO DO TOKEN'
      request['Content-Type'] = 'application/json'
      request['X-Cosmos-Token'] = 'AUTH_TOKEN'
      response = http.request(request)
      puts response.body
    
      $url = 'https://api.cosmos.bluesoft.io/gtins/7891910000197.json';
      $agent = 'SUBSTITUIR PELO USER AGENT INFORMADO LOGO ABAIXO DO TOKEN';
      $headers = array(
        "Content-Type: application/json",
        "X-Cosmos-Token: AUTH_TOKEN"
      );

      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_USERAGENT, $agent);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_FAILONERROR, true);

      $data = curl_exec($curl);
      if ($data === false || $data == NULL) {
        var_dump(curl_error($curl));
      } else {
        $object = json_decode($data);

        var_dump($object);
      }

      curl_close($curl);
    
      curl -i -X GET \
        -A 'SUBSTITUIR PELO USER AGENT INFORMADO LOGO ABAIXO DO TOKEN' \
        -H "Content-Type:application/json" \
        -H "X-Cosmos-Token:AUTH_TOKEN" \
        'https://api.cosmos.bluesoft.io/gtins/7891910000197.json'
    
      import urllib2
      import json

      headers = {
          'X-Cosmos-Token': 'AUTH_TOKEN',
          'Content-Type': 'application/json',
          'User-Agent': 'SUBSTITUIR PELO USER AGENT INFORMADO LOGO ABAIXO DO TOKEN'
      }

      req      = urllib2.Request('https://api.cosmos.bluesoft.io/gtins/7891910000197.json', None, headers)
      response = urllib2.urlopen(req)
      data     = json.loads(response.read())

      print json.dumps(data, indent=4)
    
Clique aqui para baixar o projeto em Delphi de exemplo.
      var str,url: string;
      begin
      try
          url := 'https://api.cosmos.bluesoft.com.br/gtins/7891910000197.json';

          IdHTTP1.Request.ExtraHeaders.Values['X-Cosmos-Token']:='AUTH_TOKEN';
          IdHTTP1.Request.ContentType := 'application/json;charset=UTF-8';
          IdHTTP.Request.UserAgent := 'SUBSTITUIR PELO USER AGENT INFORMADO LOGO ABAIXO DO TOKEN'

          Memo1.Clear;

          Screen.Cursor := crHourGlass;
          str := IdHTTP1.Get(url);

          except on E: Exception do
        Begin
          Memo1.Lines.Add('Resposta da exceção:');
          Memo1.Lines.Add('--> '+E.Message);
        End;
      end;

      Memo1.Lines.Add('HTTP Status Code:');
      Memo1.Lines.Add('--> '+IdHTTP1.ResponseText);

      Memo1.Lines.Add('Resposta da consulta:');
      Memo1.Lines.Add('--> ' + UTF8Decode(str));

      Screen.Cursor := crDefault;
    
      using System;
      using System.Net;
      using System.Net.Http;
      using System.Net.Http.Headers;

      class Cosmos
      {
          static void Main(string[] args) {
              var url = "https://api.cosmos.bluesoft.io/gtins/7891910000197.json";
              CosmosWebClient wc = new CosmosWebClient();
              string response = wc.DownloadString(url);
              Console.Write(response);
          }

          public class CosmosWebClient : WebClient {
              protected override WebRequest GetWebRequest(Uri address) {
                  HttpWebRequest request = (HttpWebRequest) base.GetWebRequest(address);
                  request.UserAgent="SUBSTITUIR PELO USER AGENT INFORMADO LOGO ABAIXO DO TOKEN";
                  request.Headers["X-Cosmos-Token"] = "AUTH_TOKEN";
                  base.Encoding = System.Text.Encoding.UTF8;
                  return request;
              }
          }
      }
    
 $.ajax({type: 'GET', url: 'https://api.cosmos.bluesoft.io/gtins/7891910000197.json', dataType: 'jsonp', headers: {'Content-Type': 'application/json', 'X-Cosmos-Token': 'AUTH_TOKEN'} }).done(function(data) {alert(data); }); 
Return Above Query
{
    "avg_price": 2.99,
    "brand": {
        "name": "UNIÃO",
        "picture": ""
    },
    "description": "AÇÚCAR REFINADO UNIÃO 1KG",
    "gpc": {
        "code": "10000043",
        "description": "Açúcar / Substitutos do Açúcar (Não perecível)"
    },
    "gross_weight": 1000,
    "gtin": 7891910000197,
    "height": 0.0,
    "length": 0.0,
    "max_price": 2.99,
    "ncm": {
        "code": "17019900",
        "description": "Outros",
        "full_description": "Açúcares e produtos de confeitaria - Açúcares de cana ou de beterraba e sacarose quimicamente pura, no estado sólido - Outros: - Outros"
    },
    "net_weight": 1000,
    "price": "R$ 2,99",
    "thumbnail": "https://cdn-cosmos.bluesoft.com.br/products/7891910000197",
    "width": 0.0
}
Valorizamos a sua privacidade

Usamos cookies para melhorar a sua experiência em nosso site. Ao clicar em "OK" você concorda com a utilização de todos os nossos cookies. Você poderá, ainda, aceitar apenas os cookies estritamente necessários, ou, ainda, gerenciar os cookies conforme sua preferência, ao clicar em “Gerenciar Cookies".
Para mais detalhes, acesse nosso, Privacy Notice