# Solid Pod with API

**URL:** <https://forum.solidproject.org/t/solid-pod-with-api/6590>\
**Category:** General Discussion\
**Created:** [May 16, 2023, 6:36am UTC](https://forum.solidproject.org/t/solid-pod-with-api/6590 "2023-05-16T06:36:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rebu.Thomas](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/rebu.thomas/32/3903_2.png) [@Rebu.Thomas](https://forum.solidproject.org/u/Rebu.Thomas)\
**Post date:** [May 16, 2023, 6:36am UTC](https://forum.solidproject.org/t/solid-pod-with-api/6590/1 "2023-05-16T06:36:34Z")

</div>

Hi,  
I am building an app which gets data from an API in json format and this data needs to be pushed to my solid pod hosted in Community Solid Server. I am new to solid concept. Can I know the best way to accomplish this task?

---

<div class="post-metadata">

**Author:** ![jeswr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeswr/32/3924_2.png) [@jeswr](https://forum.solidproject.org/u/jeswr)\
**Post date:** [May 16, 2023, 1:44pm UTC](https://forum.solidproject.org/t/solid-pod-with-api/6590/2 "2023-05-16T13:44:17Z")

</div>

Since you are dealing with plain json which is a non-RDF resource, then the easiest thing for you to do would be to use a library like [solid-client](https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/read-write-files/#write-a-file) to POST this non-RDF json resource to your Pod.

**[PERSONALLY RECOMMENDED APPROACH]** If you want to be able to re-use this data across applications that don’t understand the specific API that you’re using. Then I would first find appropriate vocabulary(s) to describe your data in RDF (you can find some here for instance [Linked Open Vocabularies](https://lov.linkeddata.es/dataset/lov/)) and then have a bit of logic on your side that converts your JSON to RDF. This could be as simple as

```ts
import { Store, Datafactory as DF } from 'n3';
import { fromRdfjsDataset } from 'solid-client';

const myApiPayload = await (await fetch('http://example.org/myAPI')).json();

const myStore = new Store([
  DF.quad(
    DF.namedNode(myApiPayload.id),
    DF.namedNode("http://xmlns.com/foaf/0.1/name"),
    DF.literal(myApiPayload.name),
  ),
  DF.quad(
    DF.namedNode(myApiPayload.id),
    DF.namedNode("http://xmlns.com/foaf/0.1/name"),
    DF.literal(myApiPayload.age, "http://www.w3.org/2001/XMLSchema#integer"),
  ),
  DF.quad(
    DF.namedNode(myApiPayload.id),
    DF.namedNode("http://xmlns.com/foaf/0.1/dob"),
    DF.literal(myApiPayload.birthday, "http://www.w3.org/2001/XMLSchema#date"),
  ),
]);

const dataset = fromRdfjsDataset(store);
await saveSolidDatasetAt(
    /* url to save dataset at in Pod */,
    dataset,
    { fetch: fetch } // fetch function from authenticated session, see https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/read-write-data/
  );

```
