Getting Started with the Spawner API

Original article can be found here (source): Artificial Intelligence on Medium

Getting Started with the Spawner API

Your quick guide to creating value in no time.

At Spawner, our mission is to enable every business and independent creator on Earth to realize the value of Machine Learning in their applications. To do this, we’ve built a platform that enables:

  • the developer/engineer to build ML-enabled applications without advanced knowledge of statistics
  • the data analyst and data scientist to build ML-enabled applications without advanced knowledge of frontend or backend engineering
  • the creator to build simple ML-enabled applications without engineering or statistics knowledge

We’ve taken this approach to build an API and sample applications that are applicable across industries such as: finance, manufacturing, supply chain, and more.

Here’s the definitive guide to getting started.

Generating a Secret API Token.

Note: Register for an account at https://spawner.ai before continuing.

The first step to accessing the Spawner API is getting a token. This secret token is what allows you to access the API remotely from any piece of code, application, or browser.

You’ll also see your message usage tracked at the top. This is the limit for how much usage you can get out of the API with the plan you are paying for. Any time you use the API, your usage will increase, but your quota will stay the same unless you upgrade your account.

Using your token.

Note: Do not expose your Secret Token. Do not share or expose this token publicly. Others will be able to use your messages with your token. If your token is exposed, don’t panic, just visit the console to regenerate your token.

All endpoints in the Spawner API need a token to be usable. Endpoints are just parts of the API exposed over the web. They can be consumed from a number of places: your browser, your terminal, your application, etc.

For example, if I enter the following question into my browser, with my token at the end:

I’ll get a standard JSON response:

Not familiar with JSON? No problem. We’ll explain how to use this data in a minute.

Getting started with the API.

Note: the base URL for the API: https://spawnerapi.com

To get full use out of the API, you can view the docs which elaborate on all the available endpoints: https://spawner.gitbook.io/spawner-docs/

An endpoint is an exposed piece of the API that you can access with a simple GET or POST request.

In the case of GET, it’s really simple. Let’s take the /fundamentals endpoint for example:

Notice the URL? https://spawnerapi.com/fundamentals/<token>

If you copy that into your browser you’ll get back an error. You need to replace <token> with the relevant fields. In the case of /fundamentals, you input any natural language about stocks or the markets and get back an answer. For <token>, you’ll put in the Secret API Token that you generated earlier.

Your refined URL might look like:

https://spawnerapi.com/fundamentals/sp_f40d10b4e48104928

See how we replaced <token> with the relevant fields?

So you’re up and running, you understand the basics, but what if you want to do more? Getting back data in a browser really isn’t useful. What if we built our API into an application? To do that, we’ll need to understand JSON a little bit more.

Understanding JSON.

JSON is a data interchange standard used across the web. It is used for passing data from one application to another. Any time you submit data to the Spawner API, you’ll get back a return in the form of JSON. JSON is usable by any programming language, making the Spawner API language agnostic.

So how can we work with JSON? JSON will work with all of your favorite technologies. Data Scientist who works with R? JSON is parsable in one line. Engineer who works with Python? You probably use JSON every day and don’t need reminded, but JSON works great with Python. Data Analyst who uses Knime, Tableau, etc.? Great! JSON will work perfectly for you as well.

In the following repository we’re building examples for using JSON in all the major languages and tools of choice:

Building and deploying your first application.

At Spawner, we get that the API might not be for everyone. So we’ve built sample applications in all sorts of different languages and technologies. We encourage you to copy these applications and make slight modifications for your specific use-case.

Requesting features & reporting bugs.

We’re in the early days of our product journey, so we expect a bug or two to be flying around. If you find something not working, please report it in the following location: