# Programmatic API

In many cases it's useful to start Platformatic Gateway using an API instead of
command line, e.g. in tests we want to start and stop our server.

The `create` function allows that:

```js
import { create } from '@platformatic/gateway'

const app = await create('path/to/platformatic.gateway.json')
await app.start()

const res = await fetch(app.url)
console.log(await res.json())

// do something

await app.close()
```

It is also possible to customize the configuration:


```js
import { create } from '@platformatic/gateway'

const app = await create('/path/to', {
  server: {
    hostname: '127.0.0.1',
    port: 0
  },
  gateway: {
    applications: [
      {
        id: 'auth-service',
        origin: 'https://auth-service.com',
        openapi: {
          url: '/documentation/json',
          prefix: 'auth'
        }
      },
      {
        id: 'payment-service',
        origin: 'https://payment-service.com',
        openapi: {
          file: './schemas/payment-service.json'
        }
      }
    ]
  }
})

await app.start()

const res = await fetch(app.url)
console.log(await res.json())

// do something

await app.close()
```


# Issues

If you run into a bug or have a suggestion for improvement, please
[raise an issue on GitHub](https://github.com/platformatic/platformatic/issues/new).