import requests
import hashlib
API_KEY = "YOUR_API_KEY"
def create_hash_id(url):
return hashlib.sha256(url.encode()).hexdigest()[:16]
def compose_items_array():
urls = [
"https://www.google.com/search?q=nikola+tesla&gl=us&hl=en",
"https://www.google.com/search?q=alexander+the+great&gl=us&hl=en",
"https://www.google.com/search?q=google+solar+eclipse&gl=us&hl=en",
"https://www.google.com/search?q=crispr&gl=us&hl=en",
"https://www.google.com/search?q=genghis%20khan&gl=us&hl=en"
]
return [{"custom_id": create_hash_id(url), "url": url} for url in urls]
def start_batch(items):
payload = {
"items": items
}
headers = {"Authorization": f"Bearer {API_KEY}"}
response = requests.post(
"https://api.olostep.com/v1/batches",
headers=headers,
json=payload
)
return response.json()["id"]
if __name__ == "__main__":
items = compose_items_array()
batch_id = start_batch(items)
print("Batch started. ID:", batch_id)