Skip to content

Creating the API

Adam Juhos edited this page Jan 14, 2019 · 4 revisions

Welcome to API Core!

This library will help you create model-based multi-level APIs.

These APIs are providing endpoints based on the data models you create, so endpoints are (mostly) created automatically, while the data model (entities and relations) will be created by you.

Once you connect your models with relations, your API will become multi-level, so you will be able to query related models using the automatically generated endpoints.

But to create your first API, you must build the project structure first.

1. Installing api-provider

API Core is a modular platform built of multiple NPM packages. API Provider is the package which will help you composing your API using the API Core packages. So, first you have to install this package:

 $ npm install --save api-provider

2. Creating your API

Every API must have at least one consumable version. So you have to create a version for your API:

const { ApiProvider } = require('api-provider')
const provider = new ApiProvider(),
      api = provider.version('1.0')

Congratulations, you have created your first API! :)

The next step is to add your edges. You should create a directory for these:

 $ mkdir edges

And inform API Provider about it:

api.edgeDir(`${__dirname}/v1.0/edges`)

Now you are ready to create your first edge.

Clone this wiki locally