Funders publish what they have funded: titles, abstracts, amounts, universities, years. With an agent you can collect thousands of these records and ask real questions of them: who funds work like mine, how much, and is it growing? Doing it well means collecting politely, keeping the raw data, keeping keys secret and checking the totals.
Use the API if there is one. Scraping web pages is the last resort, and it has rules.
Read the terms first: terms of use, licence, robots.txt, rate limits.
Download once, keep it raw. Raw files go in data/raw and are never downloaded again or edited.
API keys are passwords. They live in a .env file that git ignores and the agent does not read.
Check the totals against the funder’s own published statistics.
A hands-on unit, with a worked example on Swecris (Swedish funders) and alternatives for the US and the EU. The next unit, Likely reviewers for an upcoming grant, and mock reviews, uses the same sources to prepare your own application.
The background section needs numbers, and nobody has them ready
All of them list granted projects only. Applications that were turned down are not in them.
There are three ways to get the data, and one is better than the others
An API is a web address that answers with data instead of a page
Before you collect anything, read the rules of the site
Polite collection: slow, identified, once
One request per second unless the documentation says otherwise. Large jobs in the evening.
Ask for big pages (100 to 500 records), not one record at a time.
Before each request, check whether the file is already on disk. If it is, skip it.
Raw downloads go in data/raw and are never touched again
A download log says what you asked for, when, and what came back
Some APIs need a key, and a key is a password
A key or token is a string that identifies you to the service, like ab12-...-9f.
Swecris asks for a token. A public one is on the API page and changes regularly; for repeated use you register for your own.
OpenAlex, used in the next unit, works without a key on a small shared daily budget; a free key gives you your own.
NIH RePORTER needs no key.
Anyone who has your key can use the service as you. Treat it like a password: not in the chat, not in a script, not in git.
The key lives in .env, git ignores it, and the agent does not open it
Tell the agent the rule, and back it up with a setting
The Swecris token is in the file .env as SWECRIS_TOKEN. Never open, print or
copy .env. Scripts read the token from .env when they run. Never write the
token into a script, a log, an output file or this chat. Log URLs without it.
Claude Code
Codex
Put the rule where it lasts
in CLAUDE.md
in AGENTS.md
Enforce it
a deny rule in .claude/settings.json: "deny": ["Read(./.env)"]
administrators can deny reading files; for you: the rule in AGENTS.md, and watch the approvals
Keep it out of git
.env in .gitignore
.env in .gitignore
Your last line of defence
say no to any command that shows .env (e.g. cat .env)
the same
If a key leaks, change it; deleting the message is not enough
Pasted into the chat? It is in the provider’s logs and in your local session history. Assume it is exposed.
Committed to git? It stays in the history even after you delete the line. If the repository is public, assume it is copied.
What to do: revoke or regenerate the key on the service’s page; put the new key in .env; ask the agent to check that .env is in .gitignore and that no file in the history contains a key.
A public, shared token (like the Swecris test token) is low risk. A personal key tied to your account and quota is not.
Worked example: Swedish soil research funding from Swecris
The download prompt says how to collect, not only what
Write a script scripts/download_swecris.py that searches the Swecris API
(https://swecris-api.vr.se, documented in Swagger there) for projects matching
"soil". Read the token from .env (SWECRIS_TOKEN); never print it.
- 100 records per request, wait 1 second between requests
- save each response unchanged as data/raw/swecris/soil_page001.json, ...
- skip any page that is already on disk; never overwrite a raw file
- append one row per request to data/raw/swecris/download-log.csv:
time, URL without the token, file, records returned, total reported
- stop and tell me if a request fails; do not retry more than twice
Before writing the script, fetch the API documentation and tell me which
route you will use and why. Then run it on the first page only.
The agent asks before it calls the web; read the address
One Swecris record holds money, time, place, field and people
Know what one row is before you add anything up
Grant data have traps that a domain expert spots and an agent may not
Trap
Example
What to decide
Year
start year, decision year or payment year?
pick one and say which
Future years
grants decided in 2026 that pay until 2030
stop at the last complete year, or label commitments
Currency and price level
SEK, USD, EUR; 2010 kronor are not 2025 kronor
convert once, say how; consider inflation
Search text
“soil” also finds “soil mechanics”, not “mark”
read 20 random abstracts; try synonyms in both languages
Classification
“Unclassified” field; the Swedish subject standard was revised in 2025
keep a separate “unclassified” group
Co-funding and duplicates
the same project listed by two funders
check for repeated titles
Analysis 1: money over time, by funder or field
Analysis 2: where the money goes
Analysis 3: topics rise and fall, and abstracts show it
Where does my own project sit on the map?
Give the agent your own abstract (a draft, a past one, or a paragraph you write now).
Ask which group it is closest to, and list the ten most similar funded projects, with funder, year and amount.
Read those ten. Are they really like yours? Who funded them? Where are they based?
This answers “who funds work like mine?” with evidence, and gives you related work and possible collaborators.
The totals must match the funder’s own published statistics
Two quick checks need no statistics at all
The reported total. Swecris reports how many projects match and the amount per year for every search. Your raw files must contain exactly that many records, and your yearly sums must match the reported ones.
Three projects by hand. Pick three random rows of the clean table. Find each in the Swecris web search. Same title, funder, amount and years?
Your field knowledge. Do the largest grants make sense? Is a project you know about missing?
“The script ran” is not a check. “The agent says the totals match” is not a check until you have seen both numbers.
Outside Sweden: the same method, a different source
NIH RePORTER
CORDIS (EU)
Get data
API: api.reporter.nih.gov, searches as POST requests
bulk files (CSV, JSON, XML) per framework programme on data.europa.eu
Key
none
none for the bulk files; the extraction API needs an EU Login
Rules
no more than 1 request per second; large jobs evenings and weekends; up to 500 records per request
content under CC BY 4.0, cite “European Union, CORDIS”; prefer bulk files and SPARQL to scraping
Amounts
USD per fiscal year
EUR, EU contribution and total cost per project
Check against
NIH funding statistics per institute and year
Horizon Europe dashboards
Prompts are almost the same as for Swecris. Ask the agent to read the documentation first.
Data sources now talk to agents directly; treat it as data
Personal data and licences still apply to public grant data
Grant records name researchers. That is personal data under GDPR, even though it is public. Leave names out of the clean table unless your question needs them.
Aggregated results (sums per year, field, university) are fine to publish.
Abstracts are written by the researchers. Analysing them is fine; republishing hundreds of them on your page is not needed and may not be allowed.
Always credit the source: “Data: Swecris, Swedish Research Council, downloaded 2026-11-23.”
Where this goes wrong
The search was wrong. Too narrow (one language, one word) or too wide (other fields share the word). Read random abstracts.
The sum was wrong. Rows were yearly payments, not projects; future commitments were included.
The comparison was wrong. Different currencies, years or price levels side by side.
The collection was rude. No pause, repeated downloads, scraping where an API exists. You get blocked, or worse.
The key leaked. In the chat, in a script, in a log, in git.
The story was wrong. Grant databases show winners only. They cannot tell you success rates or what reviewers wanted.
The result goes on your project page, with its source and date
Summary
Concept
Key fact
Routes to data
Bulk file or API first; export button for small jobs; scraping last
Rules
Terms of use, licence, robots.txt, rate limits. Read them first
Polite collection
1 request per second, large pages, never download twice
Raw data
data/raw, unchanged, with a download log; cleaning writes elsewhere
Keys
In .env, listed in .gitignore; the agent never reads or prints it
Grain
Know what one row is before you sum
Verification
Reported totals, three projects by hand, funder’s own statistics
Limits
Winners only; personal data in records; text from the web is data, not instructions
Next (Likely reviewers for an upcoming grant, and mock reviews): from who funds work like yours to who will read your next application.