Skip to content

Commit

Permalink
Merge pull request #2 from LinkupPlatform/feat/axios
Browse files Browse the repository at this point in the history
Fix pre publish
  • Loading branch information
BruceWouaigne authored Jan 2, 2025
2 parents 02b9de6 + 7ebafc5 commit 81ef232
Show file tree
Hide file tree
Showing 23 changed files with 5,882 additions and 3,491 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/_run-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Run Tests

on:
workflow_call:

jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ["18.x", "19.x", "20.x"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm install
- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Test
run: npm run test
14 changes: 14 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: PR targeting Main

on:
workflow_dispatch:
pull_request:
branches: main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
run-tests:
uses: ./.github/workflows/_run-tests.yaml
9 changes: 9 additions & 0 deletions .github/workflows/push-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Push on Main

on:
push:
branches: main

jobs:
run-tests:
uses: ./.github/workflows/_run-tests.yaml
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish to npm

on:
release:
types: [published]

jobs:
run-tests:
uses: ./.github/workflows/_run-tests.yaml

build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"useTabs": false,
"tabWidth": 2,
"endOfLine": "lf"
}
73 changes: 71 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,71 @@
# linkup-js-sdk
A Javascript SDK for the Linkup API
# 🚀 Linkup JS/TS SDK

[![npm package](https://badge.fury.io/js/linkup-sdk.svg)](https://www.npmjs.com/package/linkup-sdk)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

A JS/TS SDK for the [Linkup API](https://linkup-api.readme.io/reference/getting-started), allowing
easy integration with Linkup's services. 🐍

## 🌟 Features

-**Simple and intuitive API client.**
- 🔍 **Supports both standard and deep search queries.**
- 🔒 **Handles authentication and request management.**

## 📦 Installation

Simply install the Linkup JS SDK using `npm` or any other package manager:

```bash
npm i linkup-sdk
```

## 🛠️ Usage

### Setting Up Your Environment

#### 1. **🔑 Obtain an API Key:**

Sign up on [Linkup](https://app.linkup.so) to get your API key.

#### 2. **⚙️ Set-up the API Key:**

Pass the Linkup API key to the Linkup Client when creating it.

```typescript
import { LinkupClient } from 'linkup-sdk';

const client = new LinkupClient({
apiKey: '<YOUR API KEY>',
});
```

### 📋 Examples

All search queries can be used with two very different modes:

- with `standard` `depth`, the search will be straightforward and fast, suited for relatively simple
queries (e.g. "What's the weather in Paris today?")
- with `deep` `depth`, the search will use an agentic workflow, which makes it in general slower,
but it will be able to solve more complex queries (e.g. "What is the company profile of LangChain
accross the last few years, and how does it compare to its concurrents?")

#### 📝 Standard Search Query

```typescript
import { LinkupClient } from 'linkup-js-sdk';

const client = new LinkupClient({
apiKey: '<YOUR API KEY>',
});

const askLinkup = async () => {
return await client.search({
query: 'Can you tell me which women were awared the Physics Nobel Prize',
depth: 'standard',
outputType: 'sourcedAnswer',
});
};

askLinkup().then(console.log);
```
36 changes: 36 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import js from '@eslint/js';
import typescript from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import prettier from 'eslint-plugin-prettier';
import eslintConfigPrettier from 'eslint-config-prettier';
import globals from 'globals';

export default [
js.configs.recommended,
{
files: ['**/*.ts'],
languageOptions: {
parser: tsParser,
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.node,
...globals.jest
}
},
plugins: {
'@typescript-eslint': typescript,
'prettier': prettier
},
rules: {
...typescript.configs.recommended.rules,
...eslintConfigPrettier.rules,
'prettier/prettier': ['error', {
'useTabs': false,
'tabWidth': 2
}],
'no-tabs': 'error',
'indent': ['error', 2, { 'SwitchCase': 1 }]
}
}
];
20 changes: 10 additions & 10 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/__tests__/**/*.ts", "**/?(*.)+(spec|test).ts"],
moduleFileExtensions: ["ts", "js", "json", "node"],
collectCoverage: true,
coverageDirectory: "coverage",
coverageReporters: ["text", "lcov"],
transform: {
"^.+\\.ts$": ["ts-jest", { tsconfig: "tsconfig.json" }],
},
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/__tests__/**/*.ts'],
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
collectCoverage: true,
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov'],
transform: {
'^.+\\.ts$': ['ts-jest', { tsconfig: 'tsconfig.json' }],
},
};
Loading

0 comments on commit 81ef232

Please sign in to comment.