5e-bits / 5e-srd-api Goto Github PK
View Code? Open in Web Editor NEWREST API to access D&D 5th Edition SRD database
License: MIT License
REST API to access D&D 5th Edition SRD database
License: MIT License
This API now supports docker. So it is useful to say how to run that.
Honestly, this would be kind of cool to have.
Some more possibilities to filter the monsters in a GET
-request would be great.
My ideas are the following:
monsters?alignment=chaotic_evil
monsters?type=goblin
monsters?resistance=acid
monsters?vulnerability=acid
monsters?immunity=acid
It would be great of course if they all supported multiple values, just like the challenge_rating
filter.
Hi, I've noticed that the subraces endpoint is returning a wrong encoded JSON. The mistake is here:
starting_proficiencies:: [ ],
As you can see, it's adding a wrong character ":" at the end of the array declaration. Can you fix it?
Probably Jest. I'll feel less uneasy about changing anything.
We have the technology. We can rebuild him.
A flat XP amount is given at each CR according to the SRD, as per this chart:
Thanks to @fergcb for the SRD reference
We don't need to store the XP in the actual database since we already have the CR, we can use that with a simple lookup table to determine the XP.
const CR_TO_XP = { 0: 10, 0.125: 25, 0.25: 50, 0.5: 100, 1: 200, 2: 450, 3: 700, 4: 1100, 5: 1800, 6: 2300, 7: 2900, 8: 3900, 9: 5000, 10: 5900, 11: 7200, 12: 8400, 13: 10000, 14: 11500, 15: 13000, 16: 15000, 17: 18000, 18: 20000, 19: 22000, 20: 25000, 21: 33000, 22: 41000, 23: 50000, 24: 62000, 25: 75000, 26: 90000, 27: 105000, 28: 120000, 29: 135000, 30: 155000 }
A very ugly one-liner
I think it would be nice to provide this along with the monster data so that each user that needs it doesn't need to create their own lookup tables. If others agree I would be happy to open a PR.
An "ability_bonuses"
field is returned from two endpoints, but the type description does not match the returned value.
GET api/races/{index}
actual result:
...
"ability_bonuses": [
{
"name": "CON",
"index": "con",
"bonus": 2,
"url": "/api/ability-scores/con"
}
],
...
documentation:
ability_bonuses | Racial bonuses to each of the six ability scores. | array (integer)
GET api/subraces/{index}
actual result:
...
"ability_bonuses": [
{
"name": "WIS",
"index": "wis",
"bonus": 1,
"url": "/api/ability-scores/wis"
}
],
...
documentation:
ability_bonuses | Additional ability bonuses granted by this sub race. | array (map)
Mongoose supports promise-like behavior
I think there is a better way to organize the route files with out affecting any of the actually routes.
Almost all possible ways will redirect, except for http://www.dnd5eapi.co/
We can add a redirect, however, it is best to make sure this redirect only happens in deployed environments so it doesn't cause an issue with local development.
When fetching a class, the starting equipment section returns “/api/startingequipment/{number}”.
But the api route points towards “/api/starting-equipment/{number}”
so far, only documentation for 'Classes' is up
I see a lot of weird encoding characters like this: spell’s
. Should just be spell's
.
How do we deal with this in the API?
Would it be possible to update the api from http to https? Otherwise, ever website accessing the data cannot be https.
Thank you for listening and love your api.
This can be a really simple script that runs before the server starts up so all cached endpoints are already available.
When querying for entries, it should not matter if the consumer is requesting /spells?name=Acid+Arrow
or /spells?name=acid+arrow
, it should still match the intended resource(s).
Hi,
I tried to get the app running locally but I think the DB is missing. Not sure how to setup the mongoose DB server. Is it located in your other github project (/5e-database)?
How can I get that mongo DB with the data running and working with the api server locally?
It seems you are using the heroku CLI but is it really neccessary for local development? I tried to just run the server.js script and it hangs when starting the mongoose server.
That is probably because there is no mongoose DB server ;) It is trying to start it with process.env.MONGOLAB_URI, but that is never set.
I would really like to get this working on my local, can you help?
This will allow us to have the DB repo trigger a deploy as well.
Looks like some requests are timing out at 30s. There's probably a few things that can be done to handle this.
First, using the timeout
library to drop timeouts to something reasonable, like 5s.
Second, setting up Bugsnag so there is some kind of error reporting.
Third, add more logging.
The favicon of https://dnd5eapi.co currently is the "dragon ampersand". As written on page 2 of the Player's Handbook, the dragon ampersand is a trademark of WotC, and shouldn't be used by other parties. So I guess it's best if the favicon is changed to something else.
When called by http GET, 5 cantrips have the "Level" value set to -1. Specifically:
Druidcraft
Fire Bolt
Poison Spray
Spare the Dying
Vicious Mockery
Some code formatting would be nice.
http://www.dnd5eapi.co/docs/#base
http://dnd5eapi.co/api/ redirects, most calls will redirect redirect but tools like cUrl requires an extra flag on that so better to have the right url in the first place.
This should be done based on the sample data that's in there.
This is based on an abandoned PR that I'm closing in favor of an issue.
Controllers currently use an unnecessary and confusing combination of async
/await
and .then
to handle the Promise returned by Mongoose's .find
and .findOne
, such as in the following:
exports.showSpellcastingForClass = async (req, res, next) => {
let urlString = '/api/classes/' + req.params.index;
await Spellcasting.findOne({ 'class.url': urlString })
.then(data => {
res.status(200).json(data);
})
.catch(err => {
next(err);
});
};
This PR proposes changing all instances of this pattern, dropping either the async
/await
as follows:
exports.showSpellcastingForClass = (req, res, next) => {
let urlString = '/api/classes/' + req.params.index;
Spellcasting.findOne({ 'class.url': urlString })
.then(data => {
res.status(200).json(data);
})
.catch(err => {
next(err);
});
};
Or fully embracing async
/await
syntax like so:
exports.showSpellcastingForClass = async (req, res, next) => {
let urlString = '/api/classes/' + req.params.index;
const data = await Spellcasting.findOne({ 'class.url': urlString }).catch(next);
res.status(200).json(data);
};
Something like ?challenge_rating=3
? Might be a little hairy for fractional CRs.
Examples of the spellcasting document response occur twice in the API docs. Once under the "Class" heading, for the api/classes/{index}/spellcasting
endpoint, and once for the api/spellcasting/{index}
endpoint.
The two could perhaps be merged, listing both URLs, but with the same example result, as the response for both is identical. Simple solution, should make things easier in the long run.
Alternatively, the outdated example could simply be updated. Easier for now, but more hassle in the future.
I might just need to php code help, but I have a website that uses this API for the data. When searching through the equipment, my results always return invalid when I search for any equipment packs, ie Explorer's pack (equipment/155 - 160).
I also can only however search for items like Alchemist's supplies (equipment/161-177) if I copy and paste it directly from the overall list.
The apostrophe doesn't match what the keyboard inputs.
{"name":"Scholar's Pack","url":"http://www.dnd5eapi.co/api/equipment/160"},{"name":"Alchemist’s supplies","url":"http://www.dnd5eapi.co/api/equipment/161"}
feel free to try on dnd.colinjoneill.com
This is a test.
It dumps a reference error:
ReferenceError: index is not defined
Which is because the index did get removed.
In looking through some of the recently closed issues, the database files have been updated, but when accessing the jsons through the urls, the changes are not reflected.
#32 still missing Legendary Actions from http://www.dnd5eapi.co/api/monsters/24
#48 is still incorrect in all equipment.
#11 is still missing Charisma score. http://www.dnd5eapi.co/api/monsters/1
Docker compose was working fine before commit da600ded45cb24ae0c9733b0ae4ca8f379dd2b19
. Running docker-compose up --build
now locks up during sharding of the DB after exiting with exit code: 5e-srd-api_api_1 exited with code 127
.
Log:
Step 1/6 : FROM node:12.4.0-alpine
---> d4edda39fb81
Step 2/6 : WORKDIR /app
---> Using cache
---> b7b3b122f618
Step 3/6 : COPY package.json package-lock.json /app/
---> Using cache
---> a60478496159
Step 4/6 : RUN npm install
---> Using cache
---> 2ef20360480e
Step 5/6 : COPY . /app
---> e19b20dd0f4e
Step 6/6 : CMD ["npm", "start"]
---> Running in ac712dda1de1
Removing intermediate container ac712dda1de1
---> c73fed19d7f2
Successfully built c73fed19d7f2
Successfully tagged 5e-srd-api_api:latest
Attaching to 5e-srd-api_db_1, 5e-srd-api_api_1
�[33mdb_1 |�[0m jq: error (at /tmp/docker-entrypoint-config.json:1): Cannot index string with string "systemLog"
�[33mdb_1 |�[0m jq: error (at /tmp/docker-entrypoint-config.json:1): Cannot index string with string "net"
�[33mdb_1 |�[0m 2020-01-25T18:27:52.797+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
�[36mapi_1 |�[0m /usr/local/bin/docker-entrypoint.sh: exec: line 8: exec: not found
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db2 64-bit host=d52bcf9c1819
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] db version v4.2.2
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] allocator: tcmalloc
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] modules: none
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] build environment:
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] distmod: ubuntu1804
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] distarch: x86_64
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] target_arch: x86_64
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I CONTROL [initandlisten] options: { config: "/etc/mongodb.conf", net: { bindIp: "*" }, storage: { dbPath: "/data/db2" } }
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I STORAGE [initandlisten] Detected data files in /data/db2 created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I STORAGE [initandlisten]
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
�[33mdb_1 |�[0m 2020-01-25T18:27:52.799+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3344M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
�[33mdb_1 |�[0m 2020-01-25T18:27:53.702+0000 I STORAGE [initandlisten] WiredTiger message [1579976873:702934][1:0x7fd1d74adb00], txn-recover: Recovering log 3 through 4
�[33mdb_1 |�[0m 2020-01-25T18:27:53.761+0000 I STORAGE [initandlisten] WiredTiger message [1579976873:761715][1:0x7fd1d74adb00], txn-recover: Recovering log 4 through 4
�[33mdb_1 |�[0m 2020-01-25T18:27:53.832+0000 I STORAGE [initandlisten] WiredTiger message [1579976873:832741][1:0x7fd1d74adb00], txn-recover: Main recovery loop: starting at 3/4736 to 4/256
�[33mdb_1 |�[0m 2020-01-25T18:27:53.922+0000 I STORAGE [initandlisten] WiredTiger message [1579976873:922488][1:0x7fd1d74adb00], txn-recover: Recovering log 3 through 4
�[33mdb_1 |�[0m 2020-01-25T18:27:54.107+0000 I STORAGE [initandlisten] WiredTiger message [1579976874:107594][1:0x7fd1d74adb00], txn-recover: Recovering log 4 through 4
�[33mdb_1 |�[0m 2020-01-25T18:27:54.164+0000 I STORAGE [initandlisten] WiredTiger message [1579976874:164317][1:0x7fd1d74adb00], txn-recover: Set global recovery timestamp: (0,0)
�[33mdb_1 |�[0m 2020-01-25T18:27:54.714+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
�[33mdb_1 |�[0m 2020-01-25T18:27:54.722+0000 I STORAGE [initandlisten] Timestamp monitor starting
�[33mdb_1 |�[0m 2020-01-25T18:27:54.907+0000 I CONTROL [initandlisten]
�[33mdb_1 |�[0m 2020-01-25T18:27:54.907+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
�[33mdb_1 |�[0m 2020-01-25T18:27:54.907+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
�[33mdb_1 |�[0m 2020-01-25T18:27:54.907+0000 I CONTROL [initandlisten]
�[33mdb_1 |�[0m 2020-01-25T18:27:54.926+0000 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
�[33mdb_1 |�[0m 2020-01-25T18:27:54.928+0000 I STORAGE [initandlisten] Flow Control is enabled on this deployment.
�[33mdb_1 |�[0m 2020-01-25T18:27:54.928+0000 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
�[33mdb_1 |�[0m 2020-01-25T18:27:54.928+0000 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
�[33mdb_1 |�[0m 2020-01-25T18:27:54.929+0000 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
�[33mdb_1 |�[0m 2020-01-25T18:27:54.930+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db2/diagnostic.data'
�[33mdb_1 |�[0m 2020-01-25T18:27:54.931+0000 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
�[33mdb_1 |�[0m 2020-01-25T18:27:54.931+0000 I NETWORK [initandlisten] Listening on /tmp/mongodb-27017.sock
�[33mdb_1 |�[0m 2020-01-25T18:27:54.931+0000 I NETWORK [initandlisten] Listening on 0.0.0.0
�[33mdb_1 |�[0m 2020-01-25T18:27:54.931+0000 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
�[33mdb_1 |�[0m 2020-01-25T18:27:54.931+0000 I NETWORK [initandlisten] waiting for connections on port 27017
�[33mdb_1 |�[0m 2020-01-25T18:27:55.000+0000 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>
�[36m5e-srd-api_api_1 exited with code 127
�[0mGracefully stopping... (press Ctrl+C again to force)
For any List, the results array contains objects that do not have an index.
Ex: http://www.dnd5eapi.co/api/ability-scores/ would return
{
"count": 6,
"results": [
{
"name": "STR",
"url": "http://www.dnd5eapi.co/api/ability-scores/1"
},
{
"name": "DEX",
"url": "http://www.dnd5eapi.co/api/ability-scores/2"
},
{
"name": "CON",
"url": "http://www.dnd5eapi.co/api/ability-scores/3"
},
{
"name": "INT",
"url": "http://www.dnd5eapi.co/api/ability-scores/4"
},
{
"name": "WIS",
"url": "http://www.dnd5eapi.co/api/ability-scores/5"
},
{
"name": "CHA",
"url": "http://www.dnd5eapi.co/api/ability-scores/6"
}
]
}
where instead it should return
{
"count": 6,
"results": [
{
"index": 1,
"name": "STR",
"url": "http://www.dnd5eapi.co/api/ability-scores/1"
},
{
"index": 2,
"name": "DEX",
"url": "http://www.dnd5eapi.co/api/ability-scores/2"
},
{
"index": 3,
"name": "CON",
"url": "http://www.dnd5eapi.co/api/ability-scores/3"
},
{
"index": 4,
"name": "INT",
"url": "http://www.dnd5eapi.co/api/ability-scores/4"
},
{
"index": 5,
"name": "WIS",
"url": "http://www.dnd5eapi.co/api/ability-scores/5"
},
{
"index": 6,
"name": "CHA",
"url": "http://www.dnd5eapi.co/api/ability-scores/6"
}
]
}
This will improve looped queries; otherwise it needs to parsed out from the "url" key.
This is not a useful field and changes on every Database deploy.
Really. It's too damn big. And there's really no reason not to break it up. It doesn't save much time. Unfortunately, I don't think it can be parallelized much.
Probably this one: https://github.com/semantic-release/semantic-release, probably should get added to the database repo as well.
I was trying to get some data in a vuejs app, using axios for the api calls and it seems that the http://www.dnd5eapi.co/api has no CORS settings? So browser based requests are not allowed at the moment.
Can you allow requests to the API level for browsers as well?
The endpoint for the Infernal Legacy trait is /api/traits/internal-legacy
For some endpoints, the name is also referred to as "Internal" instead of "Infernal"
It should return the leveling changes for the class, but instead I just get an empty list
Now that we have Jest and a Docker Image of the DB, we can roll out both unit and integration tests.
That would be pretty cool.
Querying /api/starting-equipment/
will result in
{
"count": 12,
"results": [
{
"index": 1,
"class": "Barbarian",
"url": "/api/starting-equipment/1"
},
...etc
]
}
The type of index in these results is inconsistent with the other endpoints, which use a string for this type.
It would be nice to rename these indices from integers to the lowercased class name.
"url":"/api/starting-equipment/barbarian"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.