Giter VIP home page Giter VIP logo

bifrost's Issues

Query.substances errors when `limit` argument is too high

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"
      ]
    }
  ]
}

Substances should have a "other names" property.

Something like this would be ideal

{
    substances(query: "Cannabis") {
        name
        alternativeNames
    }
}

->

{
  "data": {
    "substances": [
      {
        "name": "Cannabis",
        "alternativeNames": [ "Weed", "THC" ]
      }
    ]
  }
}

Query Effects of Subjective Effect Index (SEI)

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.

Mobile menu colors aren't readable

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.

query experiences

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?

Module integration

i am working with Node JS and am wondering how to integrate this module with my project since there is no NPM for it

Internal server error when querying 'shrooms', resulting in no units

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.

Some substances are returning an object instead of float for SubstanceRoaDose.treshold

According to the schema, some properties in SubstanceRoaDose should be a float, but some substances are returning an object. I saw this happening with:

  • Prochlorperazine
  • Cannabis

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"
      ]
    }
  ]
}

Query for substances can include experiences

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
    }

Use unique IDs and allow partial matches when querying for names

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"
    }
  }
}

Substance class strings have trailing hash character

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.

Basic schema text documentation

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!

Group/filter effects by type

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.

Query for all substances missing substances that are in the dataset

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.

Documentation for how to use the API via CURL, query variables

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

Screenshot 2019-05-08 at 23 06 29

Legacy API deprecation, sunset period and retirement

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.

Motivation

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.

Potential issues

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.

Roadmap

  • April 5th, 2018: Sunsetting of legacy MediaWiki API
  • April 19th, 2018: Retirement of legacy MediaWiki API

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.

Accessing with Apollo from localhost

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.

Unable to query API for 2C-B effects

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.