exa-js 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,47 @@
1
- # exasearch
1
+ # exa-js
2
+
3
+ Our official Javscript SDK. Uses `cross-fetch` under the hood.
4
+
5
+ https://www.npmjs.com/package/exa-js
6
+
7
+ ## Installation
8
+ ```
9
+ npm install exa-js
10
+ ```
11
+
12
+ ## Initialization
13
+ ```js
14
+ import Exa from "exa-node"
15
+
16
+ const exa = new Exa(process.env.EXA_API_KEY)
17
+ ```
18
+
19
+ ### `exa.search(query: string, options?: SearchOptions): Promise<SearchResponse>`
20
+ Performs a search on the Exa system with the given parameters.
21
+
22
+ ```javascript
23
+ const response = await exa.search('funny article about tech culture', {
24
+ numResults: 5,
25
+ includeDomains: ['nytimes.com', 'wsj.com'],
26
+ startPublishedDate: '2023-06-12'
27
+ });
28
+ ```
29
+
30
+ ### `exa.findSimilar(url: string, options?: FindSimilarOptions): Promise<SearchResponse>`
31
+ Finds content similar to the specified URL.
32
+
33
+ ```javascript
34
+ const response = await exa.findSimilar('https://waitbutwhy.com/2014/05/fermi-paradox.html', {
35
+ numResults: 10
36
+ });
37
+ ```
38
+
39
+ ### `exa.getContents(ids: string[] | Result[]): Promise<GetContentsResponse>`
40
+ Retrieves the contents of the specified documents.
41
+
42
+ ```javascript
43
+ const response = await exa.getContents(['8U71IlQ5DUTdsZFherhhYA', 'X3wd0PbJmAvhu_DQjDKA7A']);
44
+ ```
45
+
46
+ # Contributing
47
+ Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
package/dist/index.d.ts CHANGED
@@ -74,8 +74,8 @@ declare class Exa {
74
74
  * @param {SearchOptions} [options] - Additional search options.
75
75
  * @returns {Promise<SearchResponse>} A list of relevant search results.
76
76
  */
77
- search(query: string, options: RegularSearchOptions): Promise<SearchResponse>;
78
- searchAndContents<T extends ContentsOptions>(query: string, options: RegularSearchOptions & T): Promise<SearchResponse<T>>;
77
+ search(query: string, options?: RegularSearchOptions): Promise<SearchResponse>;
78
+ searchAndContents<T extends ContentsOptions>(query: string, options?: RegularSearchOptions & T): Promise<SearchResponse<T>>;
79
79
  /**
80
80
  * Finds similar links to the provided URL.
81
81
  * @param {string} url - The URL for which to find similar links.
@@ -83,7 +83,7 @@ declare class Exa {
83
83
  * @returns {Promise<SearchResponse>} A list of similar search results.
84
84
  */
85
85
  findSimilar(url: string, options?: FindSimilarOptions): Promise<SearchResponse>;
86
- findSimilarAndContents<T extends ContentsOptions>(url: string, options: FindSimilarOptions & T): Promise<SearchResponse<T>>;
86
+ findSimilarAndContents<T extends ContentsOptions>(url: string, options?: FindSimilarOptions & T): Promise<SearchResponse<T>>;
87
87
  /**
88
88
  * Retrieves contents of documents based on a list of document IDs.
89
89
  * @param {string | string[] | SearchResult[]} ids - An array of document IDs.
package/dist/index.js CHANGED
@@ -85,7 +85,7 @@ var Exa = class {
85
85
  return await this.request("/search", "POST", { query, ...options });
86
86
  }
87
87
  async searchAndContents(query, options) {
88
- const { text, highlights, ...rest } = options;
88
+ const { text, highlights, ...rest } = options || {};
89
89
  return await this.request("/search", "POST", {
90
90
  query,
91
91
  contents: {
@@ -105,7 +105,7 @@ var Exa = class {
105
105
  return await this.request("/findSimilar", "POST", { url, ...options });
106
106
  }
107
107
  async findSimilarAndContents(url, options) {
108
- const { text, highlights, ...rest } = options;
108
+ const { text, highlights, ...rest } = options || {};
109
109
  return await this.request("/findSimilar", "POST", {
110
110
  url,
111
111
  contents: {
package/dist/index.mjs CHANGED
@@ -51,7 +51,7 @@ var Exa = class {
51
51
  return await this.request("/search", "POST", { query, ...options });
52
52
  }
53
53
  async searchAndContents(query, options) {
54
- const { text, highlights, ...rest } = options;
54
+ const { text, highlights, ...rest } = options || {};
55
55
  return await this.request("/search", "POST", {
56
56
  query,
57
57
  contents: {
@@ -71,7 +71,7 @@ var Exa = class {
71
71
  return await this.request("/findSimilar", "POST", { url, ...options });
72
72
  }
73
73
  async findSimilarAndContents(url, options) {
74
- const { text, highlights, ...rest } = options;
74
+ const { text, highlights, ...rest } = options || {};
75
75
  return await this.request("/findSimilar", "POST", {
76
76
  url,
77
77
  contents: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exa-js",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Exasearch SDK for Node.js and the browser",
5
5
  "publishConfig": {
6
6
  "access": "public"