> ## Documentation Index
> Fetch the complete documentation index at: https://guides.affiliate.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Your First Request

> Make your first API request to search products and get affiliate links.

With your API token ready, let's make your first request: searching for products.

## Search for Products

Search products using POST with a search query.  In this example we will search the recommended "any" field,  which will compare the value to *any* text field including 'name', 'description', 'category', 'merchant' and 'brand'.

```bash theme={null}
curl -X POST https://api.affiliate.com/v1/products \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "search": [
      {"field": "any", "value": "wireless headphones", "operator": "LIKE"}
    ]
  }'
```

```javascript theme={null}
const response = await fetch('https://api.affiliate.com/v1/products', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.AFFILIATE_API_TOKEN}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    search: [
      { field: 'any', value: 'wireless headphones', operator: 'LIKE' }
    ]
  })
});
const data = await response.json();
console.log(data);
```

```python theme={null}
import requests

response = requests.post(
    'https://api.affiliate.com/v1/products',
    headers={
        'Authorization': f'Bearer {api_token}',
        'Content-Type': 'application/json'
    },
    json={
        'search': [
            {'field': 'any', 'value': 'wireless headphones', 'operator': 'LIKE'}
        ]
    }
)
print(response.json())
```

```php theme={null}
$ch = curl_init('https://api.affiliate.com/v1/products');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode([
        'search' => [
            ['field' => 'any', 'value' => 'wireless headphones', 'operator' => 'LIKE']
        ]
    ]),
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('AFFILIATE_API_TOKEN'),
        'Content-Type: application/json'
    ]
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
```

### Response

```json theme={null}
{
  "data": [
    {
         "id": "1024588527555724845",
         "barcode": "607536460997",
         "name": "Bluetooth headphones. Wireless headphones. portable",
         "description": "Binaural HD call + intelligent noise reduction. Using the most advanced Bluetooth 5.0 technology it provides faster and more stable connectivity more realistic sound and reduced power consumption. The unique stereo design provides high-quality sound allowing you to enjoy high-quality wireless music anytime anywhere. There is an intelligent digital display showing the power the headset can be connected to different devices as long as there is a Bluetooth function can be connected. Product name: Bluetooth wireless headset; Waterproof: IPX5; Bluetooth version: V5.0; Bluetooth connection range: 10 meters; Headphone battery capacity: 30mah; Charging case battery capacity: 150MA; Packaging content: a pair of earphones; 1 x charging case; 1 x data cable. Only the above packaging contents excluding other products. Note: Light reflections and different displays may cause items in the picture to be slightly different colors than the real thing. The allowable measurement error is +/-1-3cm.",
         "image_url": "https://i5.walmartimages.com/asr/90a809ec-8f4f-4c54-95e9-32d9f5862c9e.120a5f2cb2b9b9664bb90837ac480d4e.jpeg?odnHeight=450&odnWidth=450&odnBg=ffffff",
         "urls": {
            "outclick": "https://outclick.co/a/eyJpdiI6IlRrVVB3VWQxaVhFeC96VlJLblN6T3c9PSIsInZhbHVlIjoiamg4VzVUMEVKRWFVeVJ0UTBwRFpLMTNpQ1o3bGlheENQZHZUNnlKdmR3bFptOEMvNUE3NllxNGpjYjlCR21yM3gzaEwvakRPMHVmQld6bkNiQ09GMDg5YStKQzFuVkhSenp3aTZGb0lPSEJpQ0d4eTBKL21xRW1hR2JXRGJvcDZLc005SWNXRVFac0hkS1UrZmtCTWtXZ25yNm1RTzhaVmszUzQ1SWhiZzNOMmRBMW5SVGQyeGxQL3dkZjlkVDdqWkRraUxKNmxXWnRvbjhWNTFuNFgvcVhYQ0tNVG40b2UzSWFieG1BQnppb3VmbndCck1NYjRNYkdnejg2NkVSVTBmKzdyakJIQzVidmh0M29JTkdEZHp4OEl2OVlwRW1ReFBNZzlBL3JvYTV2TUVjeTdSNE9uYjhWNERHTmVEcjVPaVdsUWZESTF5VXEvcEs1TW1EakR2d3A0RXhSK09kZ3JZeGg1RWRWSUxyZUlqejFnb2dlUC96bDhlbFVQZUs4WnExK29OR3VwQWhvZlFnZ0FadUdLU3JsMHJQbVNSUGxFZ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VdKUVMzVDBJWGhYeDBiNlVXdnJoNlBTTVVqTjJUb3pOakY3cEs3NDJxUTI2S2creGxLbmlIeUxxVW5RYUhza0ZLdnJsT2ZnNE4zMHlmbDkrWm03ZEJhcjlta1FBRWpGSWlBSjBWdnN0L1VEb2JBRFA2SXMyOHg4RDJYQVZXOTI0SksrNEY1U3R0M1ZQbUJ2MisyZ1h6UnZ6UUdVcDhKZWJHSmJoRjdOcDJ2WFNrVUx0U3NNQ0Rab0JmMkxta2kwQXhwNmZQVHNSZFd3MkZiMnVCTjBFTXY3cDk4M0ErNmQvUnJmWWVQdVp1OTZaNkE3aEZqOCtWdDVXdFhCaGc4bFJHZGVUSm1UVHNCUGJscHNEOUhXZk1PTUJtUFM0YWNycHFlT042cGwyRzI1bjEzU3BRZEoxNE5XNDZLdDRkR0k4M3VjdWlDMDNUUkl4MmkzVU1ZRGtzZWxneHg4SXpYODV3S1FSRUtTRGJBOVdoRVFudz0iLCJtYWMiOiJmYTU2NmQzODI5YzgxNGFiMzcwNDFiNzYyYzU1OGQ5YTk1YmRmYzU1MWNkNjE0MTc2N2RiY2JmYjU0MzQ3ODBlIiwidGFnIjoiIn0=?affiliate_id=@@@&sub_id=###",
            "direct": "https://www.walmart.com/ip/Bluetooth-headphones-Wireless-headphones-portable/14709523111",
            "affiliate": "https://goto.walmart.com/c/@@@/1285387/9383?prodsku=14709523111&u=https%3A%2F%2Fwww.walmart.com%2Fip%2FBluetooth-headphones-Wireless-headphones-portable%2F14709523111&intsrc=CATF_9768",
            "shopnomix": "https://r.v2i8b.com/api/v1/bid/redirect?url=https%3A%2F%2Fwww.walmart.com%2Fip%2FBluetooth-headphones-Wireless-headphones-portable%2F14709523111&campaign_id=@@@"
         },
         "currency": "USD",
         "regular_price": 18.41,
         "final_price": 18.41,
         "on_sale": false,
         "sale_discount": 0,
         "availability": "InStock",
         "commissionable_status": "assumed_commissionable",
         "seller_party": "third",
         "sku": "14709523111",
         "category": "Electronics > Walmart Restored > Restored Tech > Walmart Restored Audio > Walmart Restored Headphones",
         "condition": "New",
         "network": {
            "id": 335,
            "name": "Impact US",
            "logo_url": "https://img.affiliate.com/logos/groups/10020/128x128.png"
         },
         "merchant": {
            "id": 102458,
            "name": "Walmart",
            "logo_url": "https://img.affiliate.com/logos/merchants/102458/logo.png"
         },
         "added_at": "2026-03-22 09:57:20",
         "updated_at": "2026-03-22 09:57:20"
      }
  ],
  "meta": {
    "page": 1,
    "per_page": 10,
    "total": 342
  }
}
```

## Using Affiliate Links

The response offers multiple ways to monetize products.  If you have your own merchant relationships, you can replace the '@@@' with the applicable network publisher ID and '###' with an applicable subtracking ID.

Additionally, it is recommended you take advantage of our click tracking technology by using `urls.outclick` instead of `urls.affiliate` which can be used to build a fully hydrated picture of your customer's journey.

## Handle Errors

Check the response status and handle errors:

```javascript theme={null}
const response = await fetch(url, options);

if (!response.ok) {
  const error = await response.json();
  console.error(`Error: ${error.error.code} - ${error.error.message}`);
  return;
}

const data = await response.json();
```

```python theme={null}
response = requests.get(url, headers=headers)

if not response.ok:
    error = response.json()
    print(f"Error: {error['error']['code']} - {error['error']['message']}")
else:
    data = response.json()
```

```php theme={null}
$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => $headers
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode >= 400) {
    $error = json_decode($response, true);
    echo "Error: {$error['error']['code']} - {$error['error']['message']}";
} else {
    $data = json_decode($response, true);
}
```

## Next Steps

Now that you've made your first requests, learn about integration patterns for building robust applications.
