Skip to main content

Software Heritage GraphQL Apis

Project description

This repository holds the development of Software Heritage GraphQL API. A staging version of this service is available at https://graphql.staging.swh.network

Running locally

Refer to https://docs.softwareheritage.org/devel/getting-started.html#getting-started for running software heritage services locally.

If you wish to run SWH-GraphQL independently, and have access to SWH storage services, following make targets can be used.

  • make run-dev: Use the config file at swh/graphql/config/dev.yml and start the service in auto-reload mode using uvicorn

  • make run-dev-stable: Use the config file at swh/graphql/config/dev.yml and start the service using uvicorn

  • make run-dev-docker: Run the service inside a docker container and Use the config file at swh/graphql/config/dev.yml

  • make run-wsgi-docker: Run the service inside a docker container and Use the config file at swh/graphql/config/staging.yml

  • visit http://localhost:8000 to use the query explorer

Running a query

The easiest way to run a query is using the query explorer. Please provide an SWH API token if you wish to run bigger queries.

Using curl

curl -i -H 'Content-Type: application/json' -H "Authorization: bearer your-api-token" -X POST -d '{"query": "query {origins(first: 2) {nodes {url}}}"}' http://127.0.0.1:8000

Using Python requests

import requests

url = "http://127.0.0.1:8000"
query = """
{
  origins(first: 2) {
    pageInfo {
      hasNextPage
        endCursor
    }
    edges {
      node {
        url
      }
    }
  }
}
"""
json = {"query" : query}
api_token = "your-api-token"
headers = {'Authorization': 'Bearer %s' % api_token}

r = requests.post(url=url, json=json, headers=headers)
print (r.json())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swh.graphql-0.0.9.tar.gz (57.3 kB view details)

Uploaded Source

Built Distribution

swh.graphql-0.0.9-py3-none-any.whl (85.1 kB view details)

Uploaded Python 3

File details

Details for the file swh.graphql-0.0.9.tar.gz.

File metadata

  • Download URL: swh.graphql-0.0.9.tar.gz
  • Upload date:
  • Size: 57.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.3

File hashes

Hashes for swh.graphql-0.0.9.tar.gz
Algorithm Hash digest
SHA256 1aeb035e8e19575c3195a6ca67fb77162113ce93adddf2cdd6244c2e60e4a1c5
MD5 d44923a1af2bbaee3a5ebab26875d7c2
BLAKE2b-256 071e67802347ceee9613d7922e4250c6c2a28e4588bc0b55b97e7ef892bd66e2

See more details on using hashes here.

File details

Details for the file swh.graphql-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: swh.graphql-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 85.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.3

File hashes

Hashes for swh.graphql-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 bd5b0a3398ff7d17ebfb8d998534529b441aeb23a741dedba85c4e7b584bd494
MD5 dd6fc01d0ede7d497deddad63b772959
BLAKE2b-256 9bae19e5fdb9f1c6d885fef007bc02eb07d0e622a3fff281979436ca43d1caf2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page