Skip to content

nightfallai/datasaur-example-scripts

 
 

Repository files navigation

Datasaur API Client Sample

This repository focuses on examples in Python and only covers common use cases, hence not giving all query and mutation examples. Hopefully, these illustrations will be enough to be used as a reference for other queries and mutations.

Prerequisites

  1. pip3 CLI installed
  2. Clone this repository and go to the root folder.
  3. Run pip3 install -r requirements.txt.
  4. Genereate OAuth credentials.

API Documentation

  • Start the API explanation from our GitBook.
  • For the API docs detailing the GraphQL can be accessed here.

Use Cases

  • These variables will be the same for multiple use cases below.
    • api_url: depends on the server that you request, e.g. https://app.datasaur.ai. This one should be adjusted if you're on a self hosted version.
    • client_id and client_secret: generated from OAuth credentials, see here.

Create Project

  • The detailed explanation can be accessed here.
  • Note that the process is asynchronous.
  • This is an HTTP POST multipart request because it needs to handle a list of files that will be used when creating the project.
  • Reference: /create-project-async and follow the README.

Export Project

  • The detailed explanation can be accessed here.
  • Syntax: python3 export.py <api_url> <client_id> <client_secret> <project_id> <filename> <export_format> <output_dir>

Get Projects

  • The detailed explanation can be accessed here.
  • This query returns a paginated response.
  • The input variables for the pagination can be configured directly on get_projects.json.
  • Syntax: python3 get_projects.py <api_url> <client_id> <client_secret>

Update Project Tags

  • Tag names and project ID can be specified from update_project_tags.json.
  • Two available methods: PUT and PATCH.
    • PUT method will replace all of the project tags with the input, just like PUT method on REST API.
    • PATCH method will only add new tags to a project, just like PATCH method on REST API.
  • For example, Project A has Tag1.
    • PUT ["Tag2"]: Project A will only have Tag2.
    • PATCH ["Tag2"]: Project will have both Tag1 and Tag2.
  • Syntax: python update_project_tags.py <server_url> <client_id> <client_secret> <team_id> <method>

Releases

No releases published

Packages

No packages published

Languages

  • Python 79.5%
  • TypeScript 20.5%