psychonautwiki / bifrost Goto Github PK
View Code? Open in Web Editor NEWThe PsychonautWiki API.
License: MIT License
The PsychonautWiki API.
License: MIT License
Query
query getSubstances($limit: Int, $offset: Int) {
substances(limit: $limit, offset: $offset) {
name
class {
psychoactive
chemical
}
featured
}
}
Variables
Seems to error when values higher than 51 are used.
{
"limit": 100
}
Response
{
"data": {
"substances": null
},
"errors": [
{
"locations": [
{
"column": 45,
"line": 1
}
],
"message": "Cannot destructure property `query` of 'undefined' or 'null'.",
"path": [
"substances"
]
}
]
}
I added reagent test results to the Ask The Caterpillar bot today based on the most updated information I could find. You should be able to parse this YAML file pretty easily if you want to add them to the wiki
https://github.com/estiens/caterpillar_rails/blob/master/lib/reference/reagent_test.yml
Something like this would be ideal
{
substances(query: "Cannabis") {
name
alternativeNames
}
}
->
{
"data": {
"substances": [
{
"name": "Cannabis",
"alternativeNames": [ "Weed", "THC" ]
}
]
}
}
I'm quite not sure about data structure of SEI on PsychonautWiki, however this would be valuable for users that wish to take further actions of effects, as currently they are supposed to save everything in database on the fly and there's a little lack of space.
I'm aware of that not everything will be available but let's say name
and url
is enough, just leave option to query all effects.
Wonderful and fantastic work, folks. I notcoed on the mobile menu that the background color is a dark grey and the text is black. It's barely readable. I'd recommend light text or a light background. You can run the color combination through a compliance checker for appropriate contrast.
Sincerely,
Random information architect and web designer/developer.
Hello, i'm trying to use the API, no issue with the substance
query
but now i'm trying to use the experiences
query but i have no idea on how to use it
since experiences
returns an array of Experience
, and each Experience
contains an array of Experience
etc
so the request looks like this
experiences(substance: "2C-B")
{
effects
{
effects
{
# etc
}
}
}
so this make no sense
am i missing something?
I dont know if the links provided are working but I was hopping to check them out. I listed the ones that I am having issues loading using on Tor. Maybe the site is down?
https://vvedndyt433kopnhv6vejxnut54y5752vpxshjaqmj7ftwiu6quiv2ad.onion/wiki/Main_Page
i am working with Node JS and am wondering how to integrate this module with my project since there is no NPM for it
Hello! I'm encountering an issue through DoseBot where querying for 'shrooms' does not return units. I ran this query against the API playground:
{
substances(query: "shrooms") {
name
addictionPotential
class {
chemical
psychoactive
}
tolerance {
full
half
zero
}
# routes of administration
roas {
name
dose {
units
threshold
heavy
common { min max }
light { min max }
strong { min max }
}
duration {
afterglow { min max units }
comeup { min max units }
duration { min max units }
offset { min max units }
onset { min max units }
peak { min max units }
total { min max units }
}
bioavailability {
min max
}
}
}
}
Receiving this response:
{
"errors": [
{
"message": "Float cannot represent non numeric value: { max: 0.5, min: 0.25 }",
"path": [
"substances",
0,
"roas",
0,
"dose",
"threshold"
],
"code": "INTERNAL_SERVER_ERROR"
}
],
"data": {
"substances": [
{
"name": "Psilocybin mushrooms",
"addictionPotential": "not habit-forming with a low abuse potential",
"class": {
"chemical": [
"Substituted_tryptamine"
],
"psychoactive": null
},
"tolerance": {
"full": "almost immediately after ingestion",
"half": "3 days",
"zero": "7 days"
},
"roas": [
{
"name": "oral",
"dose": {
"units": null,
"threshold": null,
"heavy": 5,
"common": {
"min": 1,
"max": 2.5
},
"light": {
"min": 0.5,
"max": 1
},
"strong": {
"min": 2.5,
"max": 5
}
},
"duration": null,
"bioavailability": null
}
]
}
]
}
}
I'm not sure if this is a bug in the API layer, or if it has to do with faulty data on PsychonautWiki, or is a problem with my query, but wanted to bring it to your attention. Also, the chemical class string looks to be non-transformed from it's database slug, and the psychoactive class is missing, but that may be another issue.
According to the schema, some properties in SubstanceRoaDose
should be a float, but some substances are returning an object. I saw this happening with:
This results in GraphQLError like the following:
{
"errors": [
{
"locations": [
{
"column": 193,
"line": 1
}
],
"message": "Float cannot represent non numeric value: { max: 2.5, min: 2 }",
"path": [
"substances",
0,
"roas",
0,
"dose",
"threshold"
]
}
]
}
When using the substance query, I observed a record that appears to be an experience.
I'd expect only substances to be returned from the substance query.
You can find the experience I observed with this query:
substances(query: "Experience:3-MeO-PCP, LSD, Clonazolam, and Amphetamine - Excessive Amounts and Excessive Confusion") {
name
url
}
I guess the main identifier for substances is its name.
Should we have an additional nonmutable id
field for Substance
and maybe Effect
?
Let's say we start using the names as the single source of truth for querying a substance. I'm not sure if this is a realistic scenario, but what if the name of a substance changes for some reason. The original query would be affected. This could lead to 404 errors, for instance.
It would also be nice to query for substances using its ID for a more assertive query. Right now, we use:
Query.substances
query {
substances(query: "LSD") {
name
}
}
{
"data": {
"substances": [
{
"name": "LSD"
}
]
}
}
The response is an array, which suggests that we could have more than 1 result. This could be helpful for search boxes, like starting to type "25" and already get a list of the 25-NB family.
But still, I couldn't query a list of more than 1 result when searching for a partial name like "25" or "L", which I assume means that the query is searching for exact matches.
On the other hand, querying for an ID or slug could be useful for loading specific pages while being sure that they won't change. In this case, the result would be a single substance:
Query.substance
query {
substance(id: "cj9mupzg00lz10155s9npo5n2") {
name
}
}
{
"data": {
"substance": {
"name": "1P-LSD"
}
}
}
This can be replicated with this query, encoded and linked here:
{
substances(query: "LSD") {
class {
chemical
psychoactive
}
}
}
The API currently responds:
{"data":{"substances":[{"class":{"chemical":["Lysergamide#"],"psychoactive":["Psychedelics#"]}}]}}
The trailing #
character is unexpected. This has been noticed in DoseBot for a few months now, and I believe it's a regression, but I'm not sure when it started happening.
Since a few days ago, Query.substances
started to error. If the query
or some other parameters are provided, it works just fine.
query {
substances {
name
}
}
{
"data": {
"substances": null
},
"errors": [
{
"locations": [
{
"column": 2,
"line": 1
}
],
"message": "Cannot destructure property `type` of 'undefined' or 'null'.",
"path": [
"substances"
]
}
]
}
Hi there,
I'm developing a harm reduction chatbot that is going to rely on pulling information from the psychnonaut wiki API. It would be super helpful to have a text document that lists the entire schema that could be returned -- something like
insufflated_afterglow_time_units, string, example value: 'minutes'
insufflated_comeup_time_units, string, example_value: 'minutes'
insufflated_dose_units, string, example_value: 'mg'
insufflated_heavy_dose, integer, example_value: 10
etc etc etc
Also, an endpoint that could return all substances that one can currently get information about.
Let me know if there's any way I could help with this, thanks!
Implement functionality reported by Tim Cools, further asked for by Alice Knag in JIRA tracking issue API-4.
It would be very helpful if the effects returned were grouped or could be filtered by their type (physical, cognitive, etc.), as currently its simply an unordered list which is fairly hard to work with.
Additionally, sorting the effects as they appear on the wiki pages would be an improvement as well.
Hello ๐
This might well be my misunderstanding of the queries available. Apologies in advance if I'm getting this confused.
If I query with a large limit and no other restrictions:
substances(limit: 999) {
name
url
}
...I receive 290 results. However, this is not all the substances available.
For example:
substances(query: "Allylescaline") {
name
url
}
...does produce a record, but that record is not included in the original (limit:999
) query.
I suppose my expectation is that the limit:999
query would return all (or, up to 999) substances.
Thanks for making this excellent resource available.
Most if not all substances are returning the summary
field as an empty string.
Query.substances
https://api.psychonautwiki.org/?query=query%7Bsubstances(query:%22MDMA%22)%7Bname%20summary%7D%7D
{
substances(query: "MDMA") {
name
summary
}
}
{
"data": {
"substances": [
{
"name": "MDMA",
"summary": ""
}
]
}
}
Hello
I know that the GraphQL is preferred as noted in #7
I also think it is good you are taking steps to make sure that this API is controlled in some way it is a very valuable resource. I also think you should be mindful of people who wish to use the API for apps as who knows what their real intentions might be
I am having difficulty understanding how the API works from the api.psychonautwiki.org
If I access the API by CURL
curl -i -H 'Content-Type: application/json' https://api.psychonautwiki.org/ -X POST -d '{"query": "query {substances {name}}"}'
I am returned
{"data":{"substances":[{"name":"1,4-Butanediol"},{"name":"1B-LSD"},{"name":"1P-ETH-LAD"},{"name":"1P-LSD"},{"name":"2-Aminoindane"},{"name":"2-FA"},{"name":"2-FEA"},{"name":"2-FMA"},{"name":"2-Fluorodeschloroketamine"},{"name":"25B-NBOH"}]}}
is this a default array that is returned? Is it possible to query more of the API by CURL?
Thank you in advance for your time
I get this message popup very often when I visit PW (logged in or not):
"Language changed from English"
Can you please make remove it?
My language is set to British (it was default).
For most substances it seems as only the oral form of administration contains dose units, the other forms of administration contain the numeric data on dose thresholds, but not the units.
For example:
https://psychonautwiki.org/w/api.php?action=browsebysubject&subject=meth
Dear developers,
we have deprecated our legacy MediaWiki API and are sunsetting it until its retirement on April 19th, 2018. Bifrost will herewith be promoted to be the default and only PsychonautWiki API.
The legacy API has regularly been used as a way of attacking the PsychonautWiki, or to scrape the wiki in ways that violate our guidelines. Even though we love all developers, protecting the sanctity of the availability of the PsychonautWiki for all users is our utmost priority.
The Bifrost API infrastructure has been engineered with efficiency in mind. Every single component has been fine-tuned to cope with high traffic scenarios -- from Redis to the in-memory LRU cache to the Varnish caching proxy between Bifrost and PW itself. It's by design scalable.
Bifrost entered sunrise almost a year ago and we urged any developer to communicate needs in that period. There are open issues, but they are not trivial to implement with the legacy MediaWiki API as well.
If you have previously used our legacy MediaWiki API to programmatically query effects et al. from the PsychonautWiki, you will need to migrate to the GraphQL API as provided by Bifrost. Please note that the legacy MediaWIKI API has never been supported by us.
Please inform us of potential issues with your client code affected by the removal of our legacy API. If you require support migrating to Bifrost or require features to be implemented, you can contact me via E-Mail at [email protected] or via Telegram.
Hello ๐
Is it possible to use the API from localhost
?
I just bootstrapped an app which will consume the API via Apollo GraphQL, and I'm getting this:
Access to fetch at 'https://api.psychonautwiki.org/' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'https://psychonautwiki.org' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I tried following the no-cors
suggestion and added the following into my Apollo configuration :
fetchOptions: {
mode: 'no-cors',
}
This will get rid of the errors, but then the server will respond with 500.
I haven't been able to get the effects data for 2C-B using the API.
Example:
{
substances(query: "2cb") {
name
# subjective effects
effects {
name url
}
}
}
Returns this:
{
"data": {
"substances": [
{
"effects": [],
"name": "2C-B"
}
]
}
}
It's able to query 2C-B itself but the effects are missing despite the wiki page containing them.
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.