# createApi

```ts
function createApi<A extends {}>(name: string, core: A): Api<A>
```

Create an Api whose implementation can be decorated within a scope.

The `core` implementation defines the API's default behavior. Use
Api.around or Scope.around to install middleware that changes
that behavior for a scope and its descendants.

### Examples
#### Example 1
```ts
import { createApi } from "effection/experimental";
import type { Operation } from "effection";

interface DatabaseApi {
  query(sql: string): Operation<{ id: number; title: string }[]>;
}

let Database = createApi<DatabaseApi>("database", {
  *query(sql) {
    console.log("running", sql);
    return [];
  },
});

export let { query } = Database.operations;
```

---
### Type Parameters
A extends &#123;&#125;
the shape of the API's core implementation


### Parameters


**name**: string


the API identifier used in debug messages


**core**: A


the default implementation for every API member
### Return Type


Api&lt;A&gt;


an API that can be invoked and decorated per scope

[View code](https://github.com/thefrontside/effection/tree/effection-v4.2.0/lib/api.ts#L38)
