# create-api

## Description

* Create a new API project based on a Swagger schema &#x20;

## Syntax

`ern create-api <apiName>`

**Arguments**

`<apiName>`

* The name to use for this API. The API name must follow Electrode Native module name rules.
* We recommend suffixing the name of API with suffix `Api`

**Options**

`--scope/-s <scope>`

* Specify a given npm scope for the API project package &#x20;
* Add the package scope automatically in the `package.json` of the generated API.
* **Default** Package will be unscoped.

`--packageName/-p <name>`

* Specify the NPM package name to use for the API.
* Add the package name automatically in the `package.json` of the generated API.
* **Default** The command will prompt for the package name to use.

`--apiVersion/-a <version>`

* Specify an initial version for the API &#x20;
* **Default**  If this option is not used, the API defaults to 0.0.1. &#x20;

`--apiAuthor/-u <author>`

* Specify the author of the API in the `package.json` file of the API &#x20;
* **Default**  If this option is not used, the author is not set. &#x20;

`--schemaPath/-m <schemaPath>`

* Generate the API using a pre-existing Swagger schema located at the given `schemaPath` &#x20;
* **Default**  If this option is not used the command uses a default starter schema to generate the initial API. You can modify this option at a later time and then regenerate the API using the `ern regen-api` command. &#x20;

`--skipNpmCheck`

* Skip the check ensuring package does not already exists in NPM registry
* **Default** The value defaults to false.&#x20;

`--manifestId <manifestId>`

* Id of the override Manifest entry to retrieve dependencies versions from (see \[override Manifest] for more info)

## Examples

`ern create-api weather`\
This example shows how to create a unscoped package named `weather-api`. The API project is located in the new directory named `weather`.

`ern create-api weather --scope MyCompany`\
This example shows how to create a scoped package named `@MyCompany/weather-api`.

`ern create-api weather --schemaPath schema.json`\
This example shows how to create a unscoped package named `weather-api`. The API project is located in the new directory named `weather`. The `--schemaPath` option specifies location of file containing pre-existing Swagger schema.

## Remarks

* The generated API project contains the API client-code for the three platforms (JavaScript, Android, and iOS) as well as any models and code to guide the implementation of the API. &#x20;
* The generated API project is meant to be published to npm and it contains the `package.json` file. &#x20;
* Once you have a version of your API ready, you should publish it to npm to make it available for people to use. Considering that the API is published to npm, you should make sure before generating the API, that the name is not already used by another API otherwise you won't be able to publish an API with a duplicate name. &#x20;
* The API project is created in a new directory named after the API project name. &#x20;

## Related commands

[ern regen-api](https://native.electrode.io/v0.38/cli-commands/regen-api) | Add a new request, event, or model to an existing API project schema and regenerate the API\
[ern create-api-impl](https://native.electrode.io/v0.38/cli-commands/create-api-impl) | Create an implementation skeleton project for a specified API

\[override Manifest]: ../platform-parts/manifest/override.md


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://native.electrode.io/v0.38/cli-commands/create-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
