Skip to content

Commit 7b974af

Browse files
committed
fix(sdk): align node client with current currents api and refresh metadata
1 parent 6ebbdbb commit 7b974af

10 files changed

Lines changed: 1044 additions & 3610 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: ["18", "20", "22"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
- name: Install dependencies
23+
run: npm install
24+
- name: Run tests
25+
run: npm test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
node_modules
22
.env
3+
*.log
4+
.DS_Store
5+
test/integration_test.js
6+
run_integration.js

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog
2+
3+
## 0.2.0
4+
5+
### Added
6+
- Added `availableLanguages()`, `availableRegions()`, and `availableCategory()` endpoint wrappers.
7+
- Added GitHub Actions CI workflow.
8+
- Added unit tests with mocked `fetch`.
9+
10+
### Changed
11+
- Migrated from module-global `API_KEY` to instance-scoped auth.
12+
- Migrated from `node-fetch` to native `fetch` (Node 18+).
13+
- Aligned `search()` and `latestNews()` parameters with the current documented API surface.
14+
- Modernized `package.json` metadata: updated repository URL, keywords, and engines.
15+
- Updated README with current docs link and usage examples.
16+
17+
### Removed
18+
- Dropped callback-style API in favor of a clean Promise-based API.
19+
- Removed legacy Babel build step and `dist/` output.
20+
21+
## 0.1.0
22+
23+
- First release of the official CurrentsAPI package.

README.md

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,63 @@
11
# currentsapi
22

3-
A node interface for CurrentsAPI.
3+
The official Node.js SDK for the [Currents API](https://currentsapi.services/en/docs/).
44

5-
Latest news headlines and metadata in JSON from 13,000 popular news sites. Powered by Currents Api
5+
## Installation
66

7-
In order to use this package you need to register at [https://currentsapi.services/en/register](https://currentsapi.services/en/register)
7+
```bash
8+
npm install currentsapi
9+
```
10+
11+
## Usage
812

9-
Please refer to our [documentation](https://currentsapi.services/en/documents) to see details about how to use the API. The convenience functions provided by this module is simply passing your options along as querystring parameters to the REST API, so the [documentation](https://currentsapi.services/en/documents) is totally valid.
13+
```js
14+
const CurrentsAPI = require('currentsapi');
15+
const api = new CurrentsAPI('YOUR_API_KEY');
16+
```
1017

11-
There are some usage examples below to see how these options should be passed in.
18+
## Endpoints
1219

13-
If you use this in a project, kindly add an attribution : 'powered by Currents API' with links back to Currents Api.
20+
### Latest News
1421

15-
## Add to your project
16-
```shell
17-
$ npm i -s currentsapi
22+
```js
23+
api.latestNews({ language: 'en' })
24+
.then(response => console.log(response));
1825
```
1926

20-
## Test
21-
```shell
22-
$ API_KEY=<your api key> npm test
27+
### Search
28+
29+
```js
30+
api.search({ keywords: 'OpenAI', language: 'en' })
31+
.then(response => console.log(response));
2332
```
2433

25-
## Example usage of API
26-
All methods support promises and node-style callbacks.
34+
Supported parameters:
35+
36+
- `keywords`
37+
- `language`
38+
- `country`
39+
- `category`
40+
- `start_date`
41+
- `end_date`
42+
43+
### Available Resources
44+
2745
```js
28-
const CurrentsAPI = require('currentsapi');
29-
const currentsapi = new CurrentsAPI('YOUR_API_KEY');
30-
31-
// To query latest news
32-
// All options passed to search are optional
33-
currentsapi.search({
34-
keywords: 'Trump',
35-
language: 'en',
36-
country: 'US'
37-
}).then(response => {
38-
console.log(response);
39-
/*
40-
{
41-
status: "ok",
42-
news: [...]
43-
}
44-
*/
45-
});
46-
47-
48-
If you like this package you can follow us at [Twitter](https://twitter.com/currentsapi)
46+
api.availableLanguages();
47+
api.availableRegions();
48+
api.availableCategory();
49+
```
50+
51+
## Authentication
52+
53+
All requests are authenticated using an `Authorization` header. Pass your API key when instantiating the client:
54+
55+
```js
56+
const api = new CurrentsAPI('YOUR_API_KEY');
57+
```
58+
59+
Get your API key at [https://currentsapi.services/en/register](https://currentsapi.services/en/register).
60+
61+
## License
62+
63+
MIT

dist/index.js

Lines changed: 0 additions & 144 deletions
This file was deleted.

0 commit comments

Comments
 (0)