# Maagizo

> API ya AfricaProxies: mipango, bei, kununua kwa salio na historia ya maagizo. Vigezo, mifano ya majibu na msimbo wa curl, Python na Node.js.

- URL: https://africaproxies.com/sw/docs/api/orders/
- Iliyoruushwa mwisho: 2026-10-15
- Mchapishi: AfricaProxies (https://africaproxies.com)

Orodhesha mipango na bei, nunua mpango kwa salio (huduma mpya, data zaidi au kuongeza muda wa porti) na usome maagizo ya zamani.

**Vituo vya maombi kwenye ukurasa huu**

- `GET /v1/catalog/products`: Bidhaa, mipango na bei
- `POST /v1/orders`: Nunua mpango kwa salio (huduma mpya, data zaidi au kuongeza muda wa porti)
- `GET /v1/orders`: Orodhesha maagizo
- `GET /v1/orders/{orderId}`: Pata agizo

URL ya msingi `https://africaproxies.com/api/v1`. Uthibitishaji, hitilafu na vikomo: angalia [muhtasari wa API](/sw/docs/api/).

## Bidhaa, mipango na bei

`GET /v1/catalog/products`

Kila bidhaa na mipango na bei zake, kama zinavyotozwa unapoagiza.

Umma: hakuna API inahitajika.

**Jibu** `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());
```

## Nunua mpango kwa salio (huduma mpya, data zaidi au kuongeza muda wa porti)

`POST /v1/orders`

Daima inalipwa kutoka salio la kulipia kabla: API huhesabu bei (bei ya katalogi × `quantity`), salio linakatwa, huduma inaundwa au muda wake unaongezwa, na agizo hurudi likiwa `completed` pamoja na `fulfillment` yake. Vitambulisho vya proxy vinapatikana mara moja.

- **Data mpya za makazi**: `{ "planId": "res-10" }`.
- **Data mpya za 4G/5G zenye anwani zinazobadilika (kwa GB)**: `{ "planId": "mgb-10" }` (usajili wa data wenye `productId: "mobile-gb"`, unaotolewa katika `fulfillment.residentialSubscriptionId`).
- **Ongeza data kwenye usajili uliopo**: `{ "planId": "res-10", "options": { "subscriptionId": "res_9x2m4k" } }`: mpango lazima uwe wa bidhaa ya usajili.
- **Porti mpya za simu**: `{ "planId": "mob-30d", "quantity": 1, "options": { "country": "AE" } }`, kwa hiari na `carrier` (angalia watoa huduma wa nchi katika [Porti za simu](/sw/docs/api/mobile/)). Mipango ya kanda inahusu nchi za kanda yake tu (vinginevyo `422` kwenye `options.country`).
- **Ongeza muda wa porti ya simu**: `{ "planId": "mob-7d", "options": { "portId": "mob_2v8k1q" } }` huongeza muda wa mpango kwenye `expiresAt`.

**Salio halitoshi → `402 insufficient_balance`**, kiasi kinachopungua na nyongeza inayopendekezwa vikiwa katika `error.details` (`missing`, `suggestedTopUp`). Hakuna fedha zinazokatwa kukiwa na hitilafu yoyote. Ili kulipa tofauti, anzisha nyongeza yenye ombi lilelile katika `purchase` (`POST /v1/topups`): mpango unanunuliwa mara salio linapoongezwa.

Uthibitishaji: funguo ya API kwenye kichwa cha `Authorization: Bearer API_KEY`.

**Parameta**

| Jina | Katika | Aina | Inahitajika | Maelezo |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | Hapana | Ufunguo wa kipekee (kwa mfano UUID) wa kurudia POST salama. Huhifadhiwa saa 24. — herufi zisizozidi 128 |

**Mwili wa ombi**

| Uwanja | Aina | Inahitajika | Maelezo |
| --- | --- | --- | --- |
| `planId` | string | Ndiyo | — |
| `quantity` | integer | Hapana | 1–100, chaguo-msingi `1` |
| `options` | object | Hapana | — |

*Mfano: Proxy za makazi*

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

*Mfano: Porti za simu*

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

*Mfano: Ongeza muda wa porti*

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

*Mfano: Data za simu*

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

*Mfano: Porti ya eneo*

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

**Jibu** `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());
```

## Orodhesha maagizo

`GET /v1/orders`

Uthibitishaji: funguo ya API kwenye kichwa cha `Authorization: Bearer API_KEY`.

**Parameta**

| Jina | Katika | Aina | Inahitajika | Maelezo |
| --- | --- | --- | --- | --- |
| `page` | query | integer | Hapana | ≥ 1, chaguo-msingi `1` |
| `perPage` | query | integer | Hapana | 1–100, chaguo-msingi `20` |
| `status` | query | `completed` · `cancelled` | Hapana | Maagizo yanaundwa yakiwa yamelipwa (fedha zimekatwa salioni). `completed` — limelipwa na kutolewa (vitambulisho vinapatikana mara moja). |
| `productId` | query | string | Hapana | Kitambulisho cha bidhaa kutoka katalogi. Thamani za AfricaProxies: `residential` (GB), `mobile` (porti maalumu za 4G/5G) na `mobile-gb` (data za 4G/5G zenye anwani zinazobadilika kwa GB). Programu lazima zivumilie thamani zisizojulikana. |

**Jibu** `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());
```

## Pata agizo

`GET /v1/orders/{orderId}`

Uthibitishaji: funguo ya API kwenye kichwa cha `Authorization: Bearer API_KEY`.

**Parameta**

| Jina | Katika | Aina | Inahitajika | Maelezo |
| --- | --- | --- | --- | --- |
| `orderId` | path | string | Ndiyo | — |

**Jibu** `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 ni mtoa huduma za proxy za IP za nyumbani kwa Afrika kusini mwa Sahara, zinazolipiwa kwa kripto bila kupakia kitambulisho.
