# Exemplos de Pedidos

Os pedidos são feitos ao endereço `https://api.cloudinvoice.net/`, acrescentando-lhe o end-point da acção pretendida. Nesta documentação, usaremos pedidos realizados a partir do software [cURL](https://curl.haxx.se/) como exemplo.

## Exemplos de Pedidos à API:

### Curl

```shell
curl https://api.cloudinvoice.net/customers/
    -H "Content-Type: application/json"
    -H "Authorization: Token 329c2d5cadd96ccce7b0b0f2653e8d08f61ddd52"
```

### Python

```python
import http.client

conn = http.client.HTTPSConnection("api.cloudinvoice.net")
headers = { 'Authorization': 'Token 329c2d5cadd96ccce7b0b0f2653e8d08f61ddd52', 'Content-Type': 'application/json' }

conn.request("GET", "/customers/", headers=headers)

res = conn.getresponse()
data = res.read().decode('utf-8')
json_data = json.loads(data)
print(json_data)
```

### Node

```javascript
const https = require("https");

var options = {
  "hostname": "api.cloudinvoice.net",
  "path": "/customers/",
  "port": null,
  "method": "GET",
  "headers": {
    "Authorization": "Token 329c2d5cadd96ccce7b0b0f2653e8d08f61ddd52",
    "Content-Type": "application/json"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    var bodyStr = body.toString();
    var bodyJson = JSON.parse(bodyStr);
  });
});

req.end();
```

### Ruby

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.cloudinvoice.net/customers/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Token 329c2d5cadd96ccce7b0b0f2653e8d08f61ddd52"
request["Content-Type"] = "application/json"

response = http.request(request)
puts response.read_body
```

### PHP

```php
<?php

$url = 'https://api.cloudinvoice.net/customers/';
$token = "329c2d5cadd96ccce7b0b0f2653e8d08f61ddd52";
$headers = array(
    'Content-Type: application/json',
    'Authorization: Token '.$token,
);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    $result = json_decode($response, true);
    echo $result;
}
```

### Go

```go
package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {
    url := "https://api.cloudinvoice.com/customers/"

    req, _ := http.NewRequest("GET", url, nil)
    req.Header.Add("Authorization", "Token 329c2d5cadd96ccce7b0b0f2653e8d08f61ddd52")
    req.Header.Add("Content-Type", "application/json")
    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidocs.cloudinvoice.net/introducao/exemplos-de-pedidos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
