Hi group,
I've added a new parameter to api/polls.json. It can help you find polls and filter poll questions.
Query: new "question" parameter
How does this differ from the existing "state" and "topic" parameters? Two ways:
1. We don't publish a list of question codes, so you'll have to guess at them. (We have 3,500 of them, and some are ... messy.)
To find them: use trial-and-error; or inspect other polls.json responses (see below); or ask on this forum.
I'll mention some question codes, so you can guess at others:
- 2016-CO-Pres-GE TrumpvClinton (works for all 50 states)
- 2016-US-Pres-GE TrumpvClinton (nationwide)
- 16-OH-Sen-GE-PvSt (works for all senate races; the "St" here is to disambiguate from "Si", and we use that pattern quite a bit)
2. "question=" doesn't filter by chart. This threw me: when you query by "state" or "topic", Pollster looks up charts matching those parameters and then finds questions that appear in those charts. (Every chart has one question.)
That means if you search by "state" or "topic" for a question that has no chart (e.g., "2016-CO-Pres-GE TrumpvClinton" as I write this, for temporary, internal reasons), you won't find its polls.
We've documented the oddity, but we can't change it because existing code might rely on it.
You don't have to switch to the "question" parameter. We'll soon publish charts for the presidency in each state and for all senate races, so you can just wait and keep doing things The Old Way. But if you'd like a head start, use question.
Response: new "question.code" value
The question code isn't the same as the question name we publish in the API.
Before, an api/polls.json response might have looked like:
"questions":[{"name":"2016 Utah Presidential GE", ...
That name is nice, but it isn't precise enough. It might mean "Clinton v Rubio", for instance.
Now, you'll get this:
"questions":[{"code":"16-UT-Pres-GE TrumpvClinton","name":"2016 Utah Presidential GE", ...
I see long-term potential in exposing our questions: our API users don't have to rely upon our charts, and they'll be able to filter our questions more easily. I hope you'll agree.
We warmly welcome your questions and comments, on- and off-list.
Enjoy life,
Adam