Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Author endpoint does not work with single author #322

Open
raffaem opened this issue Feb 14, 2025 · 6 comments
Open

Author endpoint does not work with single author #322

raffaem opened this issue Feb 14, 2025 · 6 comments

Comments

@raffaem
Copy link
Contributor

raffaem commented Feb 14, 2025

The author endpoint does not seem to work if we have a single author:

> authors_from_names <- oa_fetch(
+   entity = "authors",
+   display_name = c("Massimo Aria"),
+   has_orcid = TRUE
+ )
Warning in oa_request(oa_query(filter = filter_i, multiple_id = multiple_id,  :
  No records found!
@yjunechoe

This comment has been minimized.

@yjunechoe yjunechoe added the bug Something isn't working label Feb 14, 2025
@yjunechoe
Copy link
Collaborator

yjunechoe commented Feb 14, 2025

Please ignore the above. As documented in the search argument of ?oa_fetch():

To filter using search, append .search to the end of the attribute you're filtering for.

oa_fetch(
  entity = "authors",
  display_name.search = "Massimo Aria",
  has_orcid = TRUE
)
#> # A tibble: 1 × 15
#>   id                  display_name display_name_alterna…¹ relevance_score ids   orcid works_count
#>   <chr>               <chr>        <list>                           <dbl> <lis> <chr>       <int>
#> 1 https://openalex.o… Massimo Aria <chr [4]>                       17263. <chr> http…         199
#> # ℹ abbreviated name: ¹​display_name_alternatives
#> # ℹ 8 more variables: cited_by_count <int>, counts_by_year <list>, `2yr_mean_citedness` <dbl>,
#> #   h_index <int>, i10_index <int>, last_known_institutions <list>, topics <list>,
#> #   works_api_url <chr>```

@yjunechoe yjunechoe removed the bug Something isn't working label Feb 14, 2025
@raffaem
Copy link
Contributor Author

raffaem commented Feb 15, 2025

That doesn't work for me:

> oa_fetch(
+   entity = "authors",
+   display_name.search = "Massimo Aria",
+   has_orcid = TRUE
+ )
Error: lexical error: invalid char in json text.
                                       There was an error processing y
                     (right here) ------^
7.
parse_string(txt, bigint_as_char)
6.
parseJSON(txt, bigint_as_char)
5.
parse_and_simplify(txt = txt, simplifyVector = simplifyVector,
simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix,
flatten = flatten, ...)
4.
jsonlite::fromJSON(m, simplifyVector = FALSE) at oa_fetch.R#743
3.
api_request(query_url, ua, query = query_ls, api_key = api_key,
parse = FALSE) at oa_fetch.R#338
2.
oa_request(oa_query(filter = filter_i, multiple_id = multiple_id,
identifier = identifier, entity = entity, search = search,
options = options, group_by = group_by, endpoint = endpoint,
verbose = verbose), per_page = per_page, paging = paging, ... at oa_fetch.R#126
1.
oa_fetch(entity = "authors", display_name.search = "Massimo Aria",
has_orcid = TRUE)

@yjunechoe
Copy link
Collaborator

The error you're getting is unrelated - the OpenAlex API seems to be having a site-wide problem of handling mailto information (your contact email). See: #323

Can you try again with the mailto option set to NULL?

options(openalexR.mailto = NULL)

oa_fetch(
  entity = "authors",
  display_name.search = "Massimo Aria",
  has_orcid = TRUE
)
#> # A tibble: 1 × 15
#>   id           display_name display_name_alterna…¹ relevance_score ids   orcid works_count cited_by_count counts_by_year `2yr_mean_citedness`
#>   <chr>        <chr>        <list>                           <dbl> <lis> <chr>       <int>          <int> <list>                        <dbl>
#> 1 https://ope… Massimo Aria <chr [4]>                       10027. <chr> http…         199          12397 <df [14 × 3]>                  6.17
#> # ℹ abbreviated name: ¹​display_name_alternatives
#> # ℹ 5 more variables: h_index <int>, i10_index <int>, last_known_institutions <list>, topics <list>, works_api_url <chr>

@trangdata
Copy link
Collaborator

Thanks @raffaem for reporting! OpenAlex has just fixed this mailto issue, so June's code snippet above works for me. Could you please try again?

library(openalexR)
authors_from_names <- oa_fetch(
  entity = "authors",
  display_name.search = c("Massimo Aria"),
  has_orcid = TRUE
)
#> # A tibble: 1 × 15
#>   id             display_name display_name_alterna…¹ relevance_score ids   orcid
#>   <chr>          <chr>        <list>                           <dbl> <lis> <chr>
#> 1 https://opena… Massimo Aria <chr [4]>                       10027. <chr> http…
#> # ℹ abbreviated name: ¹​display_name_alternatives
#> # ℹ 9 more variables: works_count <int>, cited_by_count <int>,
#> #   counts_by_year <list>, `2yr_mean_citedness` <dbl>, h_index <int>,
#> #   i10_index <int>, last_known_institutions <list>, topics <list>,
#> #   works_api_url <chr>

Created on 2025-02-17 with reprex v2.0.2

@raffaem
Copy link
Contributor Author

raffaem commented Feb 17, 2025

I can't right now. Will try in a few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants