Code Monkey home page Code Monkey logo

bifrost's Introduction

 ┌──────────────────────────────────────────────────────────────────┐
 │            ______ _________________ _____ _____ _____            │
 │            | ___ \_   _|  ___| ___ \  _  /  ___|_   _|           │
 │            | |_/ / | | | |_  | |_/ / | | \ `--.  | |             │
 │            | ___ \ | | |  _| |    /| | | |`--. \ | |             │
 │            | |_/ /_| |_| |   | |\ \\ \_/ /\__/ / | |             │
 │            \____/ \___/\_|   \_| \_|\___/\____/  \_/             │
 │                                                                  │
 └──────────────────────────────────────────────────────────────────┘
                                            PsychonautWiki. REL/FOUI

~~ MIT License ~~

Copyright (c) 2016 Kenan Sulayman
Copyright (c) 2016 The PsychonautWiki Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

bifrost's People

Contributors

14h avatar 19h avatar carlfriess avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bifrost's Issues

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.

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

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.

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

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 returning experiences, joke pages, categories, classes of drugs and compounds

Hi!

I'm making a drug logging app that uses TripSit's API and PsychonautWiki's API to get data about the various drugs. I've noticed some oddities with PsychonautWiki's API in particular.

First off, here's the query:

query substances {
      substances(limit: 9999) {
        name

        roas {
          name

          dose {
            units
            threshold
            heavy
            light { min max }
            common { min max }
            strong { min max }
          }
          duration {
            total { min max units }
            onset { min max units }
            comeup { min max units }
            peak { min max units }
            offset { min max units }
            afterglow { min max units }
          }
        }

        dangerousInteractions { name }
        unsafeInteractions { name }
        uncertainInteractions { name }

        effects { name }
      }
    }

This query returns results like, categories and joke pages:

  • Antipsychotic
    
  • Cake
    
  • Classical psychedelic
    
  • Cytochrome P450 inhibitors
    
  • Deliriant
    
  • Depressant
    
  • Entactogens
    
  • Entheogen
    
  • Hallucinogens
    
  • Hypnotic
    
  • Inhalants
    
  • MAOI
    
  • Nootropic
    
  • Opioids
    
  • Prodrug
    
  • Psychedelics
    
  • Racetams
    
  • Sedative
    
  • Selective serotonin reuptake inhibitor
    
  • Serotonergic psychedelic
    
  • Serotonin-norepinephrine reuptake inhibitor
    
  • Stimulants
    
  • Substituted aminorexes
    
  • Substituted amphetamines
    
  • Substituted cathinones
    
  • Substituted morphinans
    
  • Substituted phenethylamines
    
  • Substituted phenidates
    
  • Substituted tryptamines
    
  • Synthetic cannabinoid
    
  • Thienodiazepines
    
  • Tryptamine (compound)
    

It returns results that have nothing to do with substances themselves, like these experiences:

  • Experience: I-Doser ('audio-drug') and meditation
    
  • Experience:3-MeO-PCP, LSD, Clonazolam, and Amphetamine - Excessive Amounts and Excessive Confusion
    

It also returns some questionable results, though I'm not sure if I should consider these as drugs?

  • Cannabidiol
    
  • Cannabinoid
    

Not sure if I caught them all, but I tried my best.

Is this intentional? I would assume that a substance query would only return substances, not categories, experiences and compounds. Having to write so many checks in my API parsing is difficult when there are so many results that are not substances.

Something else I noticed is that LSD for example is not returned by the query above. I haven't noticed any other drugs that are not returned, though it is hard to check when there are so many drugs to manually double check between the results of my query and the wiki itself.

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?

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.

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

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
    }

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.

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

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

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.

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.

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.

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.

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!

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.