# Oda

> API na AfricaProxies: tsare-tsare, farashi, saye daga saura da tarihin oda. Siga, misalan amsa da lambar curl, Python da Node.js.

- URL: https://africaproxies.com/ha/docs/api/orders/
- An sabunta ƙarshe: 2026-10-15
- Mai wallafa: AfricaProxies (https://africaproxies.com)

Jera tsare-tsare da farashinsu, sayi tsari daga saura (sabon aiki, ƙarin traffic ko tsawaita toshi), ka karanta odarka ta baya.

**Wuraren kira a wannan shafin**

- `GET /v1/catalog/products`: Samfura, tsare-tsare da farashi
- `POST /v1/orders`: Sayi tsari daga saura (sabon aiki, ƙarin traffic ko tsawaita toshi)
- `GET /v1/orders`: Jera oda
- `GET /v1/orders/{orderId}`: Duba oda

URL na asali `https://africaproxies.com/api/v1`. Tabbatar da shiga, kurakurai da iyaka: duba [bayanin API](/ha/docs/api/).

## Samfura, tsare-tsare da farashi

`GET /v1/catalog/products`

Kowane samfur da tsare-tsarensa da farashinsa, daidai da kuɗin da ake caji lokacin oda.

Baiwa: ba a buƙatar mabuɗin API.

**Amsa** `200 OK`

```json
{
  "data": [
    {
      "id": "residential",
      "name": "Residential proxies",
      "description": "Residential IPs across 49 African locations for public price research, local SEO and your application tests. Prepaid traffic, billed per GB.",
      "unit": "GB",
      "plans": [
        {
          "id": "res-10",
          "productId": "residential",
          "name": "Team",
          "quantity": 10,
          "unit": "GB",
          "durationDays": null,
          "price": "5.94",
          "pricePerUnit": "0.59",
          "popular": false,
          "features": [
            "Prepaid traffic never expires",
            "Country and city where available",
            "Project credentials and traffic caps"
          ],
          "available": true,
          "countries": null
        }
      ]
    }
  ]
}
```

*curl*

```bash
curl -s "https://africaproxies.com/api/v1/catalog/products"
```

*Python*

```python
import os
import requests

API = "https://africaproxies.com/api/v1"

r = requests.get(f"{API}/catalog/products", timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://africaproxies.com/api/v1';

const res = await fetch(`${API}/catalog/products`);
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## Sayi tsari daga saura (sabon aiki, ƙarin traffic ko tsawaita toshi)

`POST /v1/orders`

Koyaushe ana biya daga saura da aka riga aka biya: API yana ƙirga farashi (farashin kundin × `quantity`), a cire kuɗin daga saura, a ƙirƙiri ko tsawaita aikin, odar ta dawo `completed` tare da `fulfillment` nata. Ana samun bayanan shiga proxy nan take.

- **Sabon traffic na gida**: `{ "planId": "res-10" }`.
- **Sabon traffic na 4G/5G mai sauyawa (bisa GB)**: `{ "planId": "mgb-10" }` (biyan traffic da `productId: "mobile-gb"`, ana isarwa a `fulfillment.residentialSubscriptionId`).
- **Ƙara traffic ga biyan da yake nan**: `{ "planId": "res-10", "options": { "subscriptionId": "res_9x2m4k" } }`: dole tsarin ya kasance na samfurin biyan.
- **Sabon toshin mobile**: `{ "planId": "mob-30d", "quantity": 1, "options": { "country": "AE" } }`, tare da `carrier` idan ana so (duba kamfanonin ƙasa a [Toshin mobile](/ha/docs/api/mobile/)). Tsare-tsaren yanki suna rufe ƙasashen yankinsu kawai (in ba haka ba `422` a kan `options.country`).
- **Tsawaita toshin mobile**: `{ "planId": "mob-7d", "options": { "portId": "mob_2v8k1q" } }` yana ƙara tsawon tsarin ga `expiresAt`.

**Saura bai isa ba → `402 insufficient_balance`**, da adadin da ya rage da shawarar cika asusu a `error.details` (`missing`, `suggestedTopUp`). Ba a cire kuɗi idan an sami kowane kuskure. Don biyan bambancin, fara cika asusu da buƙata ɗaya a `purchase` (`POST /v1/topups`): ana sayen tsarin da zarar an ƙara kuɗin cika asusun.

Authentication: API madaidaiciya a cikin `Authorization: Bearer API_KEY` taken.

**Ma'aunin aiki**

| Suna | A cikin | Nau'i | Abin bukata | Bayani |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | A'a | Maɓalli na musamman (misali UUID) don sake gwada POST cikin aminci. Ana riƙe shi 24 h. — iyakar haruffa 128 |

**Sashin buƙata**

| Fasali | Nau'i | Abin bukata | Bayani |
| --- | --- | --- | --- |
| `planId` | string | I | — |
| `quantity` | integer | A'a | 1–100, tsohon saiti `1` |
| `options` | object | A'a | — |

*Misali: Na gida*

```json
{
  "planId": "res-10"
}
```

*Misali: Toshin mobile*

```json
{
  "planId": "mob-30d",
  "quantity": 1,
  "options": {
    "country": "AE",
    "carrier": "etisalat",
    "autoRenew": true
  }
}
```

*Misali: Tsawaita toshi*

```json
{
  "planId": "mob-7d",
  "options": {
    "portId": "mob_2v8k1q"
  }
}
```

*Misali: Traffic na mobile*

```json
{
  "planId": "mgb-10"
}
```

*Misali: Toshin yanki*

```json
{
  "planId": "mob-30d",
  "options": {
    "country": "AE",
    "carrier": "etisalat"
  }
}
```

**Amsa** `201 Created`

```json
{
  "id": "ord_4f8k2m9q",
  "status": "completed",
  "productId": "residential",
  "planId": "res-10",
  "planName": "Team",
  "quantity": 1,
  "unitPrice": "5.94",
  "subtotal": "5.94",
  "discount": "0.00",
  "total": "5.94",
  "promoCode": null,
  "currency": "USD",
  "topUpId": null,
  "options": {},
  "fulfillment": {
    "residentialSubscriptionId": "res_9x2m4k",
    "mobilePortIds": []
  },
  "createdAt": "2026-10-05T14:03:11Z",
  "paidAt": "2026-10-05T14:03:11Z"
}
```

*curl*

```bash
curl -s -X POST "https://africaproxies.com/api/v1/orders" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"planId":"res-10"}'
```

*Python*

```python
import os, uuid
import requests

API = "https://africaproxies.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}", "Idempotency-Key": str(uuid.uuid4())}

r = requests.post(f"{API}/orders", headers=HEADERS, json={"planId": "res-10"}, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
import { randomUUID } from 'node:crypto';

const API = 'https://africaproxies.com/api/v1';

const res = await fetch(`${API}/orders`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, 'Idempotency-Key': randomUUID(), 'Content-Type': 'application/json' },
  body: JSON.stringify({ planId: 'res-10' }),
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## Jera oda

`GET /v1/orders`

Authentication: API madaidaiciya a cikin `Authorization: Bearer API_KEY` taken.

**Ma'aunin aiki**

| Suna | A cikin | Nau'i | Abin bukata | Bayani |
| --- | --- | --- | --- | --- |
| `page` | query | integer | A'a | ≥ 1, tsohon saiti `1` |
| `perPage` | query | integer | A'a | 1–100, tsohon saiti `20` |
| `status` | query | `completed` · `cancelled` | A'a | Ana ƙirƙirar oda bayan an biya (an cire daga saura). `completed` — an biya kuma an isar (bayanan shiga suna samuwa nan take). |
| `productId` | query | string | A'a | Alamar samfur daga kundin. Zaɓuɓɓukan AfricaProxies: `residential` (GB), `mobile` (keɓaɓɓen toshin 4G/5G) da `mobile-gb` (traffic na 4G/5G mai sauyawa bisa GB). Dole shirye-shiryen abokin ciniki su jure ƙimomin da ba su sani ba. |

**Amsa** `200 OK`

```json
{
  "data": [
    {
      "id": "ord_4f8k2m9q",
      "status": "completed",
      "productId": "residential",
      "planId": "res-10",
      "planName": "Team",
      "quantity": 1,
      "unitPrice": "5.94",
      "subtotal": "5.94",
      "discount": "0.00",
      "total": "5.94",
      "promoCode": null,
      "currency": "USD",
      "topUpId": null,
      "options": {},
      "fulfillment": {
        "residentialSubscriptionId": "res_9x2m4k",
        "mobilePortIds": []
      },
      "createdAt": "2026-10-05T14:03:11Z",
      "paidAt": "2026-10-05T14:03:11Z"
    }
  ],
  "pagination": {
    "page": 1,
    "perPage": 20,
    "total": 1,
    "totalPages": 1
  }
}
```

*curl*

```bash
curl -s "https://africaproxies.com/api/v1/orders" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://africaproxies.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.get(f"{API}/orders", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://africaproxies.com/api/v1';

const res = await fetch(`${API}/orders`, {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## Duba oda

`GET /v1/orders/{orderId}`

Authentication: API madaidaiciya a cikin `Authorization: Bearer API_KEY` taken.

**Ma'aunin aiki**

| Suna | A cikin | Nau'i | Abin bukata | Bayani |
| --- | --- | --- | --- | --- |
| `orderId` | path | string | I | — |

**Amsa** `200 OK`

```json
{
  "id": "ord_4f8k2m9q",
  "status": "completed",
  "productId": "residential",
  "planId": "res-10",
  "planName": "Team",
  "quantity": 1,
  "unitPrice": "5.94",
  "subtotal": "5.94",
  "discount": "0.00",
  "total": "5.94",
  "promoCode": null,
  "currency": "USD",
  "topUpId": null,
  "options": {},
  "fulfillment": {
    "residentialSubscriptionId": "res_9x2m4k",
    "mobilePortIds": []
  },
  "createdAt": "2026-10-05T14:03:11Z",
  "paidAt": "2026-10-05T14:03:11Z"
}
```

*curl*

```bash
curl -s "https://africaproxies.com/api/v1/orders/ord_4f8k2m9q" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://africaproxies.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.get(f"{API}/orders/ord_4f8k2m9q", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://africaproxies.com/api/v1';

const res = await fetch(`${API}/orders/ord_4f8k2m9q`, {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

---

AfricaProxies: AfricaProxies mai samar da proxy na IP na gida ne ga Afirka kudu da Sahara; ana biya da kirifto ba tare da loda katin shaida ba.
