Skip to main content

Get Next Location

POST/api/v1/jobs/spiderMaps/campaigns/{campaign_id}/next

Overview

This endpoint is the core of the campaign workflow. Each call:

  1. Finds the next pending location in the campaign
  2. Automatically submits a SpiderMaps job for that location
  3. Updates campaign progress
  4. Returns job details and progress statistics
info

Workflow Pattern: Call /next in a loop until has_more is false to process all locations in a campaign.

Path Parameters

campaign_idstringrequired

The campaign ID returned from /submit

Response

has_moreboolean

true if more locations remain, false when campaign is complete

statusstring

Campaign status: active, completed, stopped

current_taskobject

Details of the submitted job (null when complete)

progressobject

Campaign progress statistics

Examples

Basic Usage

curl -X POST https://spideriq.ai/api/v1/jobs/spiderMaps/campaigns/camp_lu_restaurants_abc123/next \
-H "Authorization: Bearer <your_token>"

Response (In Progress):

{
"has_more": true,
"status": "active",
"current_task": {
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"location_id": 28451,
"search_string": "restaurants Luxembourg City, Luxembourg",
"display_name": "Luxembourg City"
},
"progress": {
"total": 12,
"pending": 10,
"submitted": 2,
"completed": 0,
"failed": 0,
"percentage": 16.67
}
}

Response (Campaign Complete):

{
"has_more": false,
"status": "completed",
"current_task": null,
"progress": {
"total": 12,
"pending": 0,
"submitted": 0,
"completed": 12,
"failed": 0,
"percentage": 100.0
}
}

Complete Campaign Loop

import requests
import time

API_BASE = "https://spideriq.ai/api/v1"
TOKEN = "<your_token>"
headers = {"Authorization": f"Bearer {TOKEN}"}

# Create campaign
campaign = requests.post(
f"{API_BASE}/jobs/spiderMaps/campaigns/submit",
headers=headers,
json={"query": "restaurants", "country_code": "LU"}
).json()

campaign_id = campaign["campaign_id"]
print(f"Created campaign: {campaign_id}")
print(f"Total locations: {campaign['total_locations']}")

# Process all locations
job_ids = []
while True:
result = requests.post(
f"{API_BASE}/jobs/spiderMaps/campaigns/{campaign_id}/next",
headers=headers
).json()

if result["current_task"]:
job_ids.append(result["current_task"]["job_id"])
print(f"Submitted: {result['current_task']['display_name']} ({result['progress']['percentage']:.0f}%)")

if not result["has_more"]:
print(f"\nCampaign complete! Submitted {len(job_ids)} jobs.")
break

# Optional: small delay between submissions
time.sleep(0.5)

N8N / Xano Integration

The /next endpoint is designed for easy integration with workflow automation tools:

Loop Node:
Condition: response.has_more == true

HTTP Request:
Method: POST
URL: /api/v1/jobs/spiderMaps/campaigns/{{campaign_id}}/next

Store: response.current_task.job_id → job_ids[]

Wait: 500ms (optional)

Error Responses

Campaign Not Found

{
"detail": "Campaign not found: invalid_campaign_id"
}

Campaign Already Completed

When calling /next on an already-completed campaign:

{
"has_more": false,
"status": "completed",
"current_task": null,
"progress": {
"total": 12,
"pending": 0,
"submitted": 0,
"completed": 12,
"failed": 0,
"percentage": 100.0
}
}