Skip to main content

Access your python functions through HTTP requests.

Project description

Spine API

Access your python functions through HTTP requests.

It is simple, clean, and easy to use. It works with jupyter notebooks too.

1. Setup your api server


  1. Make sure your server is accessible through port 3000
  2. Have Node.js installed on your server


$ git clone
$ cd spine-api/server
$ npm install

Run server

$ node server.js

Now you can access your server through http://YOUR_SERVER_IP:3000. Copy the passcode.


$ pip instal spineapi

Connect your python script to the server

1. Import the library

from spineapi import Connection

2. Define your function

def hello_function (input):
  # ...
  # do something
  # ...
  return output

3. Specify name and description to initialize your project

spine_connection = Connection(
  project_name="My first project",
  description="Arithmetic operations",
  author="", # Optional
  link="" # Optional

4. Register your function(s)

  # ============ Optional ==================
  # Set True if you want to protect this API
  # ========================================

The function will be accessible through /api/hello_project/hello_function

5. Run

That's it! You can now communicate with your ML model through HTTP post requests.

6. Send requests

Note You have to first run JSON.stringify(input) for the request data.

const data = {
  input: JSON.stringify(YOUR_INPUT)
  // ============ Optional ==================
  // Required if the API is protected
  authToken: "xxx",
  // ========================================

Post request body to the endpoint.

const url = 'http://localhost:3000/api/hello_project/hello_function';

    method: 'POST',
    body: JSON.stringify(data),
    headers: new Headers({ 'Content-Type': 'application/json' })
.then(res => res.json())
.catch(error => console.error('Error:', error))
.then(response => console.log('Success:', response));



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

spineapi-0.1.0.tar.gz (3.3 kB view hashes)

Uploaded source

Built Distribution

spineapi-0.1.0-py3-none-any.whl (5.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page