-
-
Save phoenix-mossimo/e3dcb08a18329b786c62a8e288f39dbe to your computer and use it in GitHub Desktop.
Fetch Zenodo stats for communities and queries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To use this script you need to have "curl" and "jq" installed. | |
COMMUNITY_ID="craft-oa" | |
OUTPUT_CSV="${COMMUNITY_ID}_community_stats.csv" | |
# Create CSV file header | |
echo "URL,DOI,Title,PublicationDate,Views,Downloads" > "${OUTPUT_CSV}" | |
# Download all records (including multiple versions) from the community (max 10k records) | |
curl -s -G "https://zenodo.org/api/records/" -d "size=10000" -d "all_versions=true" -d "communities=${COMMUNITY_ID}" \ | |
`# Process with jq to extract the required fields` \ | |
| jq -r '.hits.hits[] | [.links.self, .metadata.doi, .metadata.title, .metadata.publication_date, .stats.views, .stats.downloads] | @csv' \ | |
>> "${OUTPUT_CSV}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To use this script you need to have "curl" and "jq" installed. | |
QUERY="grants.code:12345" | |
OUTPUT_CSV="[${QUERY}]_query_stats.csv" | |
# Create CSV file header | |
echo "URL,DOI,Title,PublicationDate,Views,Downloads" > "${OUTPUT_CSV}" | |
# Download all records (including multiple versions) for the query (max 10k records) | |
curl -s -G "https://zenodo.org/api/records/" -d "size=10000" -d "all_versions=true" -d "q=${QUERY}" \ | |
`# Process with jq to extract the required fields` \ | |
| jq -r '.hits.hits[] | [.links.self, .metadata.doi, .metadata.title, .metadata.publication_date, .stats.views, .stats.downloads] | @csv' \ | |
>> "${OUTPUT_CSV}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To use this script you need to have "curl" and "jq" installed. | |
USER_ID="12345" | |
OUTPUT_CSV="${USER_ID}_user_stats.csv" | |
# Create CSV file header | |
echo "URL,DOI,Title,PublicationDate,Views,Downloads" > "${OUTPUT_CSV}" | |
# Download all records (including multiple versions) for the user (max 10k records) | |
curl -s -G "https://zenodo.org/api/records/" -d "size=10000" -d "all_versions=true" -d "q=owners:${USER_ID}" \ | |
`# Process with jq to extract the required fields` \ | |
| jq -r '.hits.hits[] | [.links.self, .metadata.doi, .metadata.title, .metadata.publication_date, .stats.views, .stats.downloads] | @csv' \ | |
>> "${OUTPUT_CSV}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment