Skip to content

Commit 07d1d8a

Browse files
author
vikas kumar
committed
add crypto endpoint and update md
1 parent fcfa3b4 commit 07d1d8a

9 files changed

Lines changed: 183 additions & 75 deletions

File tree

README.md

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
12
![Alt text](https://raw.githubusercontent.com/newsdataapi/python-client/main/newsdata-logo.png)
23

3-
# <p align="center">Newsdataapi Python Client
4+
# <p align="center">NewsData.io Python Client
45
newsdataapi allows you to create a library for accessing http services easily, in a centralized way. An API defined by newsdataapi will return a JSON object when called.
56

67
[![Build Status](https://img.shields.io/github/workflow/status/newsdataapi/python-client/Upload%20Python%20Package)](https://github.com/newsdataapi/python-client/actions/workflows/python-publish.yml)
@@ -42,17 +43,17 @@ api = NewsDataApiClient(apikey="API key")
4243
response = api.news_api()
4344
4445
```
45-
`API key` : Your private Newsdata API key.
46+
`API key` : Your private Newsdata API key.
4647

47-
`country` : You can pass a comma seperated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to. Possible Options: `us` `gb` `in` `jp` `ae` `sa` `au` `ca` `sg`
48+
`country` : You can pass a comma seperated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to. Possible Options: `us` `gb` `in` `jp` `ae` `sa` `au` `ca` `sg`
4849

4950
`category` : A comma seperated string of categories (maximum 5) to restrict the search to. Possible Options: `top`, `business`, `science`, `technology`, `sports`, `health`, `entertainment`
5051

5152
`language` : A comma seperated string of languages (maximum 5) to restrict the search to. Possible Options: `en`, `ar`, `jp`, `in`, `es`, `fr`
5253

5354
`domain` : A comma seperated string of domains (maximum 5) to restrict the search to. Use the /domains endpoint to find top sources id.
54-
55-
`q` : Keywords or phrases to search for in the news title and content. The value must be URL-encoded. Advance search options: Search Social q=social, Search "Social Pizza" q=social pizza, Search Social but not with pizza. social -pizza q=social -pizza, Search Social but not with pizza and wildfire. social -pizza -wildfire q=social -pizza -wildfire, Search multiple keyword with AND operator. social AND pizza q=social AND pizza
55+
56+
`q` : Keywords or phrases to search for in the news title and content. The value must be URL-encoded. Advance search options: Search Social q=social, Search "Social Pizza" q=social pizza, Search Social but not with pizza. social -pizza q=social -pizza, Search Social but not with pizza and wildfire. social -pizza -wildfire q=social -pizza -wildfire, Search multiple keyword with AND operator. social AND pizza q=social AND pizza
5657

5758
`qInTitle` : Keywords or phrases to search for in the news title only.
5859

@@ -76,9 +77,9 @@ api = NewsDataApiClient(apikey="API key")
7677
response = api.archive_api()
7778
7879
```
79-
`API key` : Your private Newsdata API key.
80+
`API key` : Your private Newsdata API key.
8081

81-
`country` : You can pass a comma seperated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to. Possible Options: `us` `gb` `in` `jp` `ae` `sa` `au` `ca` `sg`
82+
`country` : You can pass a comma seperated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to. Possible Options: `us` `gb` `in` `jp` `ae` `sa` `au` `ca` `sg`
8283

8384
`category` : A comma seperated string of categories (maximum 5) to restrict the search to. Possible Options: `top`, `business`, `science`, `technology`, `sports`, `health`, `entertainment`
8485

@@ -89,8 +90,8 @@ response = api.archive_api()
8990
`from_date` : A date and optional time for the oldest article allowed. This should be in ISO 8601 format (e.g. `2021-04-18` or `2021-04-18T04:04:34`)
9091

9192
`to_date` : A date and optional time for the newest article allowed. This should be in ISO 8601 format (e.g. `2021-04-18` or `2021-04-18T04:04:34`)
92-
93-
`q` : Keywords or phrases to search for in the news title and content. The value must be URL-encoded. Advance search options: Search Social q=social, Search "Social Pizza" q=social pizza, Search Social but not with pizza. social -pizza q=social -pizza, Search Social but not with pizza and wildfire. social -pizza -wildfire q=social -pizza -wildfire, Search multiple keyword with AND operator. social AND pizza q=social AND pizza
93+
94+
`q` : Keywords or phrases to search for in the news title and content. The value must be URL-encoded. Advance search options: Search Social q=social, Search "Social Pizza" q=social pizza, Search Social but not with pizza. social -pizza q=social -pizza, Search Social but not with pizza and wildfire. social -pizza -wildfire q=social -pizza -wildfire, Search multiple keyword with AND operator. social AND pizza q=social AND pizza
9495

9596
`qInTitle` : Keywords or phrases to search for in the news title only.
9697

@@ -115,14 +116,45 @@ api = NewsDataApiClient(apikey="API key")
115116
response = api.sources_api()
116117
117118
```
118-
`API key` : Your private Newsdata API key.
119+
`API key` : Your private Newsdata API key.
119120

120-
`country` : Find sources that display news in a specific country. Possible Options: `us` `gb` `in` `jp` `ae` `sa` `au` `ca` `sg`
121+
`country` : Find sources that display news in a specific country. Possible Options: `us` `gb` `in` `jp` `ae` `sa` `au` `ca` `sg`
121122

122123
`category` : Find sources that display news of this category. Possible Options: `top`, `business`, `science`, `technology`, `sports`, `health`, `entertainment`
123124

124125
`language` : Find sources that display news in a specific language. Possible Options: `en`, `ar`, `jp`, `in`, `es`, `fr`
125126

127+
<br />
128+
129+
### Crypto News API
130+
131+
`GET /1/crypto`
132+
133+
```
134+
from newsdataapi import NewsDataApiClient
135+
136+
# API key authorization, Initialize the client with your API key
137+
api = NewsDataApiClient(apikey="API key")
138+
139+
# You can pass empty or with request parameters {ex. (country = "us")}
140+
response = api.crypto_api()
141+
142+
```
143+
`API key` : Your private Newsdata API key.
144+
145+
`country` : You can pass a comma seperated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to. Possible Options: `us` `gb` `in` `jp` `ae` `sa` `au` `ca` `sg`
146+
147+
`language` : A comma seperated string of languages (maximum 5) to restrict the search to. Possible Options: `en`, `ar`, `jp`, `in`, `es`, `fr`
148+
149+
`domain` : A comma seperated string of domains (maximum 5) to restrict the search to. Use the /domains endpoint to find top sources id.
150+
151+
`q` : Keywords or phrases to search for in the news title and content. The value must be URL-encoded. Advance search options: Search Bitcoin q=bitcoin Search "Bitcoin Ethereum" q=bitcoin ethereum Search Bitcoin but not with Ethereum q=bitcoin -ethereum Search Bitcoin but not with Ethereum and Dogecoin bitcoin -ethereum -dogecoin q=bitcoin -ethereum -dogecoin Search multiple keyword with AND operator bitcoin AND ethereum q=bitcoin AND ethereum .
152+
153+
`qInTitle` : Keywords or phrases to search for in the news title only.
154+
155+
`page` : Use this to page through the results if the total results found is greater than the page size.
156+
157+
126158
<br />
127159

128160
## License
@@ -136,4 +168,4 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
136168
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
137169
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
138170
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
139-
```
171+
```

examples/ex_newsdataapi_request.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@
1717

1818
# Sources API
1919
response = api.sources_api()
20-
print(response)
20+
print(response)
21+
22+
# Crypto API
23+
response = api.crypto_api()
24+
print(response)

newsdataapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from newsdataapi.newsdataapi_client import NewsDataApiClient
1+
from newsdataapi.newsdataapi_client import NewsDataApiClient

newsdataapi/constants.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# All the Newsdata supported API URL
22
BASE_URL = 'https://newsdata.io/api/1/'
33

4-
# Latest News URL
4+
# Latest News URL
55
NEWS_URL = BASE_URL + 'news'
66

77

8-
# News Archive URL
8+
# News Archive URL
99
ARCHIVE_URL = BASE_URL + 'archive'
1010

1111

12-
# News Sources URL
12+
# News Sources URL
1313
SOURCES_URL = BASE_URL + 'sources'
1414

1515

16-
# Default request timeout is 300 seconds
17-
DEFAULT_REQUEST_TIMEOUT = 300
16+
# News Crypto URL
17+
CRYPTO_URL = BASE_URL + 'crypto'
18+
19+
20+
# Default request timeout is 300 seconds
21+
DEFAULT_REQUEST_TIMEOUT = 300

newsdataapi/helpers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ def MaxRetries(response, max_retries, retry_delay, request_method, URL, URL_para
1414
break
1515
max_retries-=1
1616
return response
17-
18-

0 commit comments

Comments
 (0)