# Ghost Content-Api Not Working

**URL:** <https://forum.ghost.org/t/ghost-content-api-not-working/5346>\
**Category:** Developer help\
**Created:** [January 29, 2019, 12:25pm UTC](https://forum.ghost.org/t/ghost-content-api-not-working/5346 "2019-01-29T12:25:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rubel](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/rubel/32/242_2.png) [@Rubel](https://forum.ghost.org/u/Rubel)\
**Post date:** [January 29, 2019, 12:25pm UTC](https://forum.ghost.org/t/ghost-content-api-not-working/5346/1 "2019-01-29T12:25:37Z")

</div>

Ghost Content-aapi V2 not working for me. showing the following error

**ReferenceError: GhostContentAPI is not defined**

```auto
const api = new GhostContentAPI({
  host: 'http://localhost:2368',
  key: '5aa0b27939b29ddbc13d97fb8f',
  version: 'v2'
}); 

```

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [January 29, 2019, 1:06pm UTC](https://forum.ghost.org/t/ghost-content-api-not-working/5346/2 "2019-01-29T13:06:30Z")

</div>

@Rubel did you follow the [installation instructions](https://docs.ghost.org/api/javascript/#installation)? The snippet you’ve provided isn’t enough to diagnose where the problem may be as you haven’t included any information about what environment you’re trying to run in or how you’ve installed the required npm package

---

<div class="post-metadata">

**Author:** ![Rubel](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/rubel/32/242_2.png) [@Rubel](https://forum.ghost.org/u/Rubel)\
**Post date:** [January 29, 2019, 3:24pm UTC](https://forum.ghost.org/t/ghost-content-api-not-working/5346/3 "2019-01-29T15:24:44Z")

</div>

```plaintext
npm install @tryghost/content-api

```

i install it , and in package.json file added

```plaintext
    "engines": {
        "ghost": ">=2.0.0",
        "ghost-api": "v2"
    },

```

but it not working . i got the data from const apiUrl = “[http://localhost:2368/ghost/api/v2/content/posts/?key=5aa0b27939b29ddbc13d97fb8f&include=tags,authors](http://localhost:2368/ghost/api/v2/content/posts/?key=5aa0b27939b29ddbc13d97fb8f&include=tags,authors)”; also.

---

<div class="post-metadata">

**Author:** ![Rubel](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/rubel/32/242_2.png) [@Rubel](https://forum.ghost.org/u/Rubel)\
**Post date:** [January 29, 2019, 3:56pm UTC](https://forum.ghost.org/t/ghost-content-api-not-working/5346/4 "2019-01-29T15:56:49Z")

</div>

It Works Finally By Adding The Script In default.hbs.

```auto
 <script src="https://unpkg.com/@tryghost/content-api@1.0.0/umd/content-api.min.js"></script>
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/ba9ce5100b8bb264586f4f572545596b2ce3f081.png) [@system](https://forum.ghost.org/u/system)\
**Post date:** [February 12, 2019, 4:09pm UTC](https://forum.ghost.org/t/ghost-content-api-not-working/5346/5 "2019-02-12T16:09:52Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
