Skip to content

Commit e510e5a

Browse files
committed
edit for engrXiv
1 parent 541e620 commit e510e5a

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
Requirements and Background
22
-------------
33

4-
In order to access the API you will need an API Token. Tokens are unique to each user and should not be shared. As such, no token is included in this repository. To get your token, first login to the <a href="https://osf.io">OSF site</a>. Once logged in, click on your name in the top right corner and select "Settings". In the Settings menu that now appears on the left, select "Personal Access Tokens". The "New Token" button will generate a new token specific to your account.
4+
In order to access the API you will need an API Token. Tokens are unique to each user and should not be shared. As such, no token is included in this repository. To get your token, first login to the <a href="https://osf.io">OSF site</a>. Visit [https://osf.io/settings/tokens/](https://osf.io/settings/tokens/). The "New Token" button will generate a new token specific to your account.
5+
6+
Once you have the token, open the file named `api_token.py` and paste your token in place of `AUTHTOKEN1.
57

6-
Once you have the token, create a file named api_token.py with one line in it:
7-
```python
8-
osf_token = "BLAH"
9-
```
10-
where BLAH should be replaced with your token. The code will import api_token.py and reference osf_token when making calls to the API.
118

129
TO DO
1310
---------

api_token.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
osf_token = "AUTHTOKEN"

eartharxiv_api.py renamed to engrxiv_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
# API URL to list all preprint providers
1212
api_url_providers = "https://api.osf.io/v2/preprint_providers"
1313

14-
# API URL to search/download preprints, NOTE: this is currently hard-coded to search EarthArXiv
15-
api_url_search = "https://api.osf.io/v2/preprints/?filter[provider]=eartharxiv"
14+
# API URL to search/download preprints, NOTE: this is currently hard-coded to search engrxiv
15+
api_url_search = "https://api.osf.io/v2/preprints/?filter[provider]=engrxiv&filter[reviews_state][ne]=initial"
1616

1717
# Set up the headers to be sent as part of every API request
1818
# osf_token is unique to each user and needs to be obtained from OSF site, it's imported from api_token.py
1919
headers = {'Content-Type': 'application/json',
2020
'Authorization': 'Bearer {0}'.format(osf_token)}
2121

22-
# Send a request to the search API, this example just asks for all preprints at EarthArXiv
22+
# Send a request to the search API, this example just asks for all preprints at engrxiv
2323
response = utils.queryAPI(api_url_search, headers)
2424

2525
# Check the response status code, 200 indicates everything worked as expected

utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def parsePreprints( preprints, json_object, headers, verbose=True ):
4545

4646
# Also need to extract scalar values like id and construct the download link
4747
id = json_object['data'][i]['id']
48-
html_link = "https://eartharxiv.org/" + id
49-
download_link = "https://eartharxiv.org/" + id + "/download"
48+
html_link = "https://engrxiv.org/" + id
49+
download_link = "https://engrxiv.org/" + id + "/download"
5050
if ( verbose ): print( "Working on preprint ", len(preprints)+1 ) # should be 1 when len=0, thus the +1
5151

5252
# Create a Preprint object to store all the information on this preprint

0 commit comments

Comments
 (0)