How to consume a GraphQL API (https://api.loggi.com)

3

I would like to understand and know the opinions to apply in a project with urgency ... I currently own a shopping site and need to use the loggi company API which is a distribution company the api link is link , I have already used their old methods to query the price of the cep but to do more robust searches like Login, order tracking, etc ... they tell me to use the new method that is with GraphQL, I already created a project on node. js using simple location like Hello World, but I do not understand how to configure it to run for example the script below that is to locate the registered cities

$ curl -v 'https://staging.loggi.com/graphql?' \
>     -H 'content-type: application/json' \
>     -H 'authorization: ApiKey [email protected]:a-valid-api-key' \
>     --compressed \
>     --data-binary '{"query":"query { allCities { edges { node { pk name slug } } } }"}'
>
> POST /graphql? HTTP/1.1
> Host: staging.loggi.com
> content-type: application/json
> ApiKey [email protected]:a-valid-api-key
>
< HTTP/1.1 200 OK
< Content-Type: application/json
<
{"data":{"allCities":{"edges":[{"node":{"pk":4,"name":"Curitiba","slug":"ct"}},{"node":{"pk":1,"name":"S\u00e3o Paulo","slug":"sp"}},{"node":{"pk":2,"name":"Rio de Janeiro","slug":"rj"}},{"node":{"pk":3,"name":"Belo Horizonte","slug":"bh"}},{"node":{"pk":5,"name":"Porto Alegre","slug":"pa"}}]}}}

Has anyone used this API or any similar APIs? (I do not know if CURL would be a js request or by GraphQL itself)

Note: My site is made in Asp.net WebForms and sorry for ignorance due to lack of knowledge, I did research and more research on GraphQL and I just understood that it is a easy way to read an API. From what I researched also the CURL would be equivalent to WebRequest in C #, am I sure?

 {
        "transport_type": 1,
        "city": 1,
        "addresses": [
            {
                "by": "cep",
                "query": {
                    "cep": "01426000",
                    "number": 300
                }
            },
            {
                "by": "address",
                "query": {
                    "category": "Rua",
                    "address": "Oscar Freire",
                    "number": 100
                }
            }
        ]
    }
    
asked by anonymous 28.09.2017 / 15:04

2 answers

0

I accessed Api, and you need to create a login to the site through this link:

link

After that, you should access this link:

link

For your Key to be generated, then you just need to use the API normally in C #.

    
02.10.2017 / 15:17
0

Hello

In order to be able to consume a GraphQL API you need a client to be able to do the middleware between GraphQL and its application below some:

17.12.2017 / 21:49