# Earliest Occurrence Records

**URL:** <https://discourse.gbif.org/t/earliest-occurrence-records/3345>\
**Category:** Data Use\
**Created:** [May 11, 2022, 9:42pm UTC](https://discourse.gbif.org/t/earliest-occurrence-records/3345 "2022-05-11T21:42:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pengelstad\_csu](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@pengelstad\_csu](https://discourse.gbif.org/u/pengelstad_csu)\
**Post date:** [May 11, 2022, 9:42pm UTC](https://discourse.gbif.org/t/earliest-occurrence-records/3345/1 "2022-05-11T21:42:32Z")

</div>

I’m starting work on a project where we’re pulling information on the earliest records for a couple thousand species (with coordinates). I know the API supports greater than, less than, etc. But is there good way to “pre-sort” the results by date?

For reference, I’m usually using rgbif but I’m open to calling the API directly in R. Any ideas, folks?

---

<div class="post-metadata">

**Author:** ![jwaller](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jwaller](https://discourse.gbif.org/u/jwaller)\
**Post date:** [May 16, 2022, 2:06pm UTC](https://discourse.gbif.org/t/earliest-occurrence-records/3345/2 "2022-05-16T14:06:13Z")

</div>

There is no way to pre-sort occurrence records using the API.

Your solution will need window-through early years…

```nohighlight
occ_search(taxonKey=212,search="year=1600,1700",limit=1000)$data %>% 
arrange(year) %>% 
select(year)

```

This will not be guaranteed to get the earliest records unless you make the window (“year=1600,1700”) small enough.

Depending on what your end goal is, it might be easier to use `occ_download()`.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/gbif1/original/1X/d2525d53d815eb0c992cc44730ed8a6a1be1dbb5.png) [@system](https://discourse.gbif.org/u/system)\
**Post date:** [June 16, 2022, 12:06am UTC](https://discourse.gbif.org/t/earliest-occurrence-records/3345/3 "2022-06-16T00:06:15Z")

</div>

Closed on June 16, 2022, 12:06am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
