# onium

> a lib you can make query to thegraph project hosted services and subgraphs.

Latest version **1.1.0** (published 2023-04-06) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install onium
pnpm add onium
yarn add onium
bun add onium
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2023-04-06 |
| First published | 2023-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Keyhan Alizadeh |
| Maintainers | kehiy |
| Keywords | thegraph, blockchain, web3, web.03, nft, query, http, queryhive |

## Links

- npm: https://www.npmjs.com/package/onium
- Repository: https://github.com/kehiy/Onium
- Homepage: https://github.com/kehiy/Onium#readme
- Issues: https://github.com/kehiy/Onium/issues
- npm.io page: https://npm.io/package/onium

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.3.4

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2023-04-06
- 1.0.1 — 2023-03-18
- 1.0.0 — 2023-03-13

## README

# Onium

a lib you can make query to thegraph project hosted services and subgraphs.

## Installation

Use the package manager [npm](https://www.npmjs.com/package/onium) to install Onium.

```bash
npm i onium
```

## Usage

```typescript
//! for hosted services.
import { host } from "onium";

// your hosted service endpoint:
const endpoint = "https://api.thegraph.com/subgraphs/name/[hosted-service-name]";

const query = `
{
    your graphQL query
}
`;

// make your query:
let data = await host(endpoint,query);

// get your data 😉🤞
console.log(data);






//! for subgraphs.
import { sub } from "onium";

// your subgraph endpoint:(dont change [api-key] just change [the-subgraph-id])
const endpoint = "https://gateway.thegraph.com/api/[api-key]/subgraphs/id/[the-subgraph-id]";


// your api key form : https://thegraph.com/
const apiKey = "here add your api key!";

const query = `
{
    your graphQL query
}
`;

// make your query:
let data = await sub(endpoint,query,apiKey);

// get your data 😉🤞
console.log(data);
```

### makeQuery
This function is used when you want to reuse a query several times while changing the search parameter.

usage:

```typescript
import {makeQuery} from "onium";

let myReuseableQuery = `
query {
  user(id: {ID}) {
    name
    address
  }
}
`;
const newQuery = makeQuery(myReuseableQuery,"{ID}",5);

// now you can use your query in sub or host funtion!
console.log(newQuery);
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License

[MIT](https://choosealicense.com/licenses/mit/)

---
_Source: https://npm.io/package/onium · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
