neurosnap.api module#

class neurosnap.api.NeurosnapAPI(api_key)[source]#

Bases: object

Client wrapper for interacting with the Neurosnap REST API.

Provides authenticated helpers for: - listing services and jobs - submitting jobs and monitoring status - retrieving job metadata and output files - managing job notes and sharing settings

Authentication is performed with a Neurosnap API key, and connectivity is validated during initialization.

BASE_URL = 'https://neurosnap.ai/api'#
delete_job_share(job_id)[source]#

Disables the sharing feature of a job and makes the job private.

Parameters:

job_id (str) – The ID of the job to be made private.

Return type:

None

get_job_data(job_id, share_id=None)[source]#

Fetches the config and all files from a Neurosnap job. Output files are only included once the job has completed.

Parameters:
  • job_id (str) – The ID of the job.

  • share_id (str) – The share ID, if any.

Return type:

Dict[str, Any]

Returns:

Dictionary with keys config, in, and out corresponding to config used, input files, and output files.

Raises:

HTTPError – If the API request fails.

get_job_file(job_id, file_type, file_name, save_path=None, share_id=None)[source]#

Fetches a specific file from a completed Neurosnap job and saves it to the specified path or returns it as a string if no path is provided.

Parameters:
  • job_id (str) – The ID of the job.

  • file_type (str) – The type of file to fetch (can be in or out).

  • file_name (str) – The name of the specific file to fetch.

  • save_path (Optional[str]) – The path where the file content will be saved.

  • share_id (str) – The share ID, if any.

Return type:

Optional[str]

Returns:

Contents of the file fetched as a string or None if save_path is not provided.

Raises:

HTTPError – If the API request fails.

get_job_status(job_id)[source]#

Fetches the status of a specified job.

Parameters:

job_id (str) – The ID of the job.

Return type:

str

Returns:

The status of the job.

Raises:

HTTPError – If the API request fails.

get_jobs(format_type=None)[source]#

Fetches and returns a list of submitted jobs. Optionally prints the jobs.

Parameters:

format_type (Optional[str]) –

  • “table”: Prints jobs in tabular format.

  • ”json”: Prints jobs as formatted JSON.

  • None (default): No printing.

Return type:

List[Dict]

Returns:

Submitted jobs as a list of dictionaries.

Raises:

HTTPError – If the API request fails.

get_pipeline(pipeline_id)[source]#

Fetches the pipeline data associated with a submitted Neurosnap pipeline.

Parameters:

pipeline_id (str) – The ID of the pipeline to fetch.

Return type:

Dict

Returns:

Pipeline object.

Raises:

HTTPError – If the API request fails.

get_services(format_type=None)[source]#

Fetches and returns a list of available Neurosnap services. Optionally prints the services.

Parameters:

format_type (Optional[str]) –

  • “table”: Prints services in a tabular format with key fields.

  • ”json”: Prints services as formatted JSON.

  • None (default): No printing.

Return type:

List[Dict]

Returns:

A list of dictionaries representing available services.

Raises:

HTTPError – If the API request fails.

get_team_info(format_type=None)[source]#

Fetches your team’s information if you are part of a Neurosnap Team.

Parameters:

format_type (Optional[str]) – The format to print the response: ‘table’, ‘json’, or None for no output.

Return type:

Dict

Returns:

The team information.

Raises:

HTTPError – If the API request fails.

get_team_jobs(format_type=None)[source]#

Fetches all the jobs submitted by all members of your Neurosnap Team.

Parameters:

format_type (Optional[str]) – The format to print the response: ‘table’, ‘JSON’, or None for no output.

Return type:

List[Dict]

Returns:

A list of jobs submitted by the team members.

Raises:

HTTPError – If the API request fails.

set_job_note(job_id, note)[source]#

Set a note for a submitted job.

Parameters:
  • job_id (str) – The ID of the job for which the note will be set.

  • note (str) – The note to be associated with the job.

Return type:

None

set_job_share(job_id)[source]#

Enables the sharing feature of a job and makes it public.

Parameters:

job_id (str) – The ID of the job to be made public.

Return type:

str

Returns:

The JSON response containing the share ID.

submit_job(service_name, fields, note=None)[source]#

Submit a job to the Neurosnap platform.

This function handles the submission of a job to a specified Neurosnap service using either a dictionary of input fields or a pre-constructed MultipartEncoder object.

Parameters:
  • service_name (-) – The name of the Neurosnap service (e.g., “TemStaPro”, “NetSolP”, “Boltz-1”) to submit the job to.

  • fields (-) – Either: - A dictionary mapping field names to values (which will be encoded automatically), or - A MultipartEncoder instance if you want full control over encoding. Refer to the API section of the tool’s page on https://neurosnap.ai for required field names and formats.

  • note (Optional[str]) – An optional note or tag to include in the job submission (e.g., “optimization_run_3”).

Return type:

str

Returns:

The job ID assigned to the submitted job.

Raises:

HTTPError – If the API request fails or returns a non-200 status code.

wait_job_status(job_id, delay=5)[source]#

Waits for the status of a job to either change to completed or failed.

Parameters:
  • job_id (str) – The ID of the job.

  • delay (int) – The delay between requests in seconds.

Return type:

str

Returns:

The status of the job.

Raises:

HTTPError – If the API request fails.