Content

How to Connect the GDELT API to a Research Agent (2026)

GDELT's news-search API needs no key, but it still rate-limits, and its defaults are shaped for a browser, not a model. Here's how to shape one query that fits in an agent and respect the pacing rule, until GDELT has a governed Swytchcode bundle.

EngineeringOct 30, 2026

Key takeaways

  • -GDELT's news-search API needs no credential, but it still enforces a real rate limit: "no key" doesn't mean "no limit."
  • -The default query covers three months and returns a browser-formatted page. Set a short time window, a small record count, and JSON output for anything an agent is going to read.
  • -Calls that arrive too close together get a rate-limit response asking for one request every 5 seconds. A retry loop that ignores this stays stuck there.
  • -swy search gdelt returns no provider today. Until it does, run the call from reviewed code with the pacing rule built in, or bring it in as your own provider on Business or Enterprise.

Give a research agent a public API with a generous free tier, and the failure mode usually isn't cost. It's politeness. GDELT is no exception: an agent that retries past a rate limit without backing off doesn't get an error that stops it, it just keeps asking and getting nothing useful back.

A research agent is asked for "the port strike." It calls GDELT's news-search API with that phrase and nothing else. The default search covers the last three months and answers in a page meant for a browser, not a model. The next tool call, two seconds later, asks for a different view of the same story. The API tells the client to slow down. The model retries immediately anyway. The agent now has a pile of markup, no articles actually in context, and a rate limit it keeps refreshing against.

The general problem is a limit that feels like it isn't there, because nothing about the API looks locked down, until an agent starts hammering it without pacing. Swytchcode's role is to bring a call like this inside the same allowlist, logging and backoff discipline as any other provider, even one that needs no credential at all.

The problem: a public API without a key still has limits

GDELT's news-search API needs no credential, which makes it unusually easy to drop straight into an agent without thinking about governance at all. But the defaults are built for a person clicking through a browser, not a model reading a result: a wide three-month search window, a result format meant for display, and a result count that can balloon if an agent assumes "more is better." None of that is an auth problem. It's a query shaped for the wrong reader.

GDELT is also a search that decides which articles even exist for a query, not a fetch of one page you've already chosen. That's a different kind of tool, covered in ScrapeGraph for research agents. An agent that pulls the maximum article list back and pastes all of it into the prompt isn't reading, it's dumping, and it's also the fastest way to run into the rate limit on the very next call.

How Swytchcode solves it

GDELT doesn't have a catalog bundle in Swytchcode yet, so there's no allowlist entry to turn on today. That's worth saying plainly rather than glossing over: the usual pattern of turning on one reviewed method and leaving the rest off doesn't apply to this provider until it's brought in. Business and Enterprise plans can bring their own provider so a call like this sits inside the same allowlist, policy and audit trail as every governed integration. That's the path to actually governing this call rather than trusting the agent to behave.

Until that exists, the discipline has to live in code you actually review: the pacing rule, the query shape, and the caching all get written once, by a person, rather than left to the model to reinvent on every call.

Setting up GDELT with Swytchcode

Check for a provider first, since this is the kind of thing that changes without notice:

swy search gdelt

That returns no provider today. A catalog page for the project already exists at the GDELT listing, but that listing isn't a promise that swy search returns a bundle right now. Don't invent a method ID in the meantime to make it look governed when it isn't. If a later swy search gdelt does print a name, use that name with swy get and only then swy list methods.

Policies: rate-limit backoff instead of trusting the agent to behave

GDELT's own response, when calls arrive too close together, tells the caller plainly to limit requests to one every five seconds. That gap is the pacing rule, and it's the whole fix: wait at least five seconds, then send one follow-up, not three. An agent loop that fires off two different queries back to back will trip it almost immediately, and one that treats the rate-limit response as "try again right now" will stay stuck there indefinitely.

Cache the result for the exact query string. The same question from a second user should reuse that cache inside the five-second window, not hit GDELT all over again. Treat a browser-formatted response as a bug in the query, never as text to summarize. Fix the query itself instead of asking the model to scrape a page meant for a person. API observability for this provider mostly comes down to a count of rate-limit responses against a count of article queries: a healthy research hour is a handful of calls, a broken one is hundreds of rejections and an empty summary at the end of it.

GDELT's news-search API lets a research agent ask "what's being written about this, right now" without needing a credential at all, and that's exactly what makes it easy to misuse: the defaults are shaped for a browser, not a model, and the rate limit is real even though nothing about the API looks locked down. The problem shows up as an agent either drowning in an unfiltered dump of HTML or getting stuck retrying into the same rate limit over and over. Until GDELT has a governed catalog bundle, Swytchcode's answer is to run the call through reviewed code with the same pacing, caching and logging discipline any other provider gets, with a bring-your-own-provider path on Business and Enterprise to fold it into the same allowlist as everything else.

FAQ

Does the GDELT DOC API require a key?

The DOC 2.0 examples are plain URLs with query, mode, and timespan parameters. No key parameter appears in any of those examples. You still have to pace your calls, though. No key doesn't mean no limit.

What happens if I omit format and timespan?

You get HTML, and the search covers the last three months by default. Article list mode then returns up to 75 records unless you set maxrecords, which tops out at 250 either way. Set format=json, a short timespan, and a small maxrecords for anything an agent is going to read.

How short can the time window be, and which mode should I use?

15min is the shortest timespan GDELT accepts, with 6h, days, weeks, and months also allowed. ArtList is the mode that returns the article list itself. TimelineVol returns volume over time instead, and it ignores maxrecords completely. It's the better call whenever the real question is "did coverage spike," since you don't need 25 headlines just to see a spike on a graph. Pick the mode that matches the question before you think about the count. Sort also defaults to relevance, not newest first, so add sort=datedesc whenever the user actually asked for the latest.

How do filters like sourcecountry actually work?

Operators like sourcecountry:us live inside the query parameter itself, not as a separate sibling parameter. GDELT's own documentation is explicit that the operators are part of the query value. A client that splits them out into their own URL parameter won't filter the way the author intended at all.

What exactly does the rate-limit response ask for?

HTTP 429, with a message that says to limit requests to one every 5 seconds. Callers that hit the API too quickly get this back almost immediately. Wait out the five seconds and send one follow-up, not three. Retrying right away just keeps triggering the same response.

Can I pull a year of coverage?

STARTDATETIME and ENDDATETIME have to sit inside the last three months, full stop. A longer history is simply outside this endpoint's reach. Narrow the question, or reach for a different archive entirely.

Can I build an AI agent on top of GDELT with Swytchcode?

Not as a governed catalog bundle today. swy search gdelt returns no provider. You can still have an agent call the public URL from code you review, with the five-second wait and the query shape built in. Business and Enterprise plans can bring GDELT in as their own provider, which is the path that puts it inside the same allowlist as every other integration.

Can Swytchcode stop an agent from hammering GDELT past the rate limit, even if it's asked to?

Once GDELT is brought in as a provider, yes. Policy and audit apply to a brought-your-own provider the same way they apply to anything in the catalog. Until that happens, the honest answer is that the backoff has to be built into the reviewed code making the call, since there's no governed bundle yet for a policy to attach to.

If an agent retries a GDELT call after a rate-limit response, will Swytchcode stop it from immediately retrying?

Not automatically for this provider today, since GDELT isn't a governed integration yet. The fix is the same five-second backoff described above, written once into the code that calls GDELT, rather than left for the agent to decide on each retry.

Use Swytchcode so this doesn't happen to you

Use Swytchcode so a research agent never floods itself with HTML and 429 responses from a GDELT query that forgot to set format, timespan, and maxrecords.

Swytchcode is an execution kernel that sits between your AI agents and the APIs they call. It resolves the right method, injects auth, checks policy, retries safely with idempotency, and logs every call locally.

Start with the MCP quickstart, or browse the docs for the full reference. Free is 100 live commands a month forever; see pricing for Pro and Business.

More content