Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

JSON api for 5e SRD?

September 17 (8 years ago)
Hello, is there an query API for the 5e SRD that will return the results in json?
September 17 (8 years ago)

Edited September 17 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
The API does not have access to the compendium. It can only get information from and modify information of entities in the game. What are you trying to do? There may be another way. Also, the API is only accessible in games created by Pro level members.
September 17 (8 years ago)
The Aaron
Roll20 Production Team
API Scripter
Just a quick separation of concepts:

The Roll20 API scripts do not have access to the compendium. 

Roll20 provides a free community accessible online SRD API. 

From: https://app.roll20.net/forum/post/2877778/update-1...
Open and community-driven. Our goal is to provide a resource that the whole community can freely use. Anyone can apply to help edit the Compendium and keep it up to date, and all of our data is freely available in JSON format; for example, here’s the Fireball entry: https://app.roll20.net/compendium/dnd5e/Fireball.json. So the next time someone wants to build a tool like an encounter builder or a spell list, they can pull from this data quickly and easily.
September 17 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
And, so I show my programming inexperience. Thanks for the correction Aaron.
September 18 (8 years ago)
The Aaron
Roll20 Production Team
API Scripter
Your statement was correct, you just weren't aware of the Compendium API. It's not accessible in the Roll20 API, just like you said. :)
September 18 (8 years ago)

Edited September 18 (8 years ago)
Thanks, I'm referring specifically to the second 'API', for the SRD.  I'm not trying to access it from the Roll20 API, I'm asking if there is a query API for the SRD data.  As in, the ability to create a query/hit endpoints on the SRD that will return the requested data in json format and not simply provide individual entries as json.  If there is an API, is it documented somewhere?

Essentially, how does one access the SRD data so that "the next time someone wants to build a tool like an encounter builder or a spell list, they can pull from this data quickly and easily."

Thanks,
September 18 (8 years ago)
The Aaron
Pro
API Scripter
There is nothing documented, but you can use this endpoint to get search results in JSON format:

https://roll20.net/compendium/compendium/globalsearch/dnd5e?terms=misty
[{"value":"Misty Step","category":"Spells","pagename":"Misty Step","score":10,"pageid":11483,"groupbyvalue":"Misty Step"},{"value":"Misty Visions","category":"Classes","pagename":"Warlock","score":7,"pageid":5209,"groupbyvalue":"Misty Visions"}]
September 20 (8 years ago)
Thanks for the response aaron.  Unfortunately that's not very useable :(
September 20 (8 years ago)
The Aaron
Pro
API Scripter
Oh?  Sorry to hear that.  It's not REST compliant, but it seems like it gives the results you would need to build the page url:
https://roll20.net/compendium/dnd5e/{category}:{pagename}.json
What more are you looking for?
September 20 (8 years ago)

Edited September 20 (8 years ago)
Sorry, that wasn't intended to be inflammatory.  That last detail is helpful.  As an example, It would be helpful to be able to get an index of all spells by class.  Well an example of that is "Wizard spells by name", which that search feature exposes as `category:Rules` and `pagename: Wizard Spells By Name`.  But, when I go to that page, the content is the list I'm looking for but can't use, and the `.json` returns just the search index

```
{
  • name: "Wizard Spells by Name",

  • id: 7047,

  • content: "{{SearchIndex|Category:Spells Classes:*Wizard|Summarize,AdditionalAttributes:School,}}",

  • data: {

    • Category: "Rules"
    }
}
```

Where I am looking for an actual array of wizard spells in json
September 20 (8 years ago)
The Aaron
Pro
API Scripter
=D  Sorry, I'm never inflamed, just tired.   I see what you mean.  Finding individual things by searching works, but getting additional indexes doesn't.  Probably you'd have to build your own index by pulling all spells and parsing the Classes property, not ideal.  Maybe there's something else, I'll see what I can find.
September 22 (8 years ago)
Thanks!

You mention "you'd have to build your own index by pulling all spells".  Is there a way to do that in one call?  Even if there was a way to get all objects for a category in a json array (ie. spells, monsters, classes(?) equipment), then that would be a good starting point.
September 23 (8 years ago)
The Aaron
Pro
API Scripter
It looks to me like if you do this:
https://roll20.net/compendium/compendium/globalsearch/dnd5e\?terms\=
You'll get everything in one go.
September 26 (8 years ago)
WOW!  That works!  thanks!