https://api.cosmos.bluesoft.io
/gtins/{code}
/gpcs/{code}
/ncms/{code}/products
/products?query={description or EAN}
/retailers/gtins/{code}
/retailers/gpcs/{code}
/retailers/ncms/{code}
/retailers/products?query={description OR EAN}
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)
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; } } }
{ "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 }