How to book a campsite in Yosemite valley

Building your own bot to co-opt natural resources

Joyce Lin
The Startup
7 min readMar 15, 2020

--

When I first moved to San Francisco from Denver several years ago, I traded in most of my outdoorsy activities for techie ones. But camping in Yosemite has been on my wish list. Year after year, I notice that it’s really tough to reserve a spot. So I’ve still never been.

There’s a bit of an issue with reserving a campsite at Yosemite, but in this case, my techie self can help out my outdoorsy self.

The problem

In 2018, a bunch of state and federal park services launched an online reservation system, Recreation.gov, allowing users to book picnic spots and campsites across America.

Located in California, Yosemite National Park is one of the most popular destinations that you can book through this website. It’s so popular that Yosemite releases a new block of campsites four months in advance.

On the 15th of every month at 7:00 a.m. Pacific Time, eager campers will scramble to book a spot at one of the prime campsites in Yosemite valley closest to the most iconic landmarks in the park.

Seconds make the difference between getting your reservation or not.

RECREATION.GOV

The competition is fierce. Thousands will try to reserve a few select spots, and the campsites will be fully booked within 20 minutes. How is this humanly possible?

There are bots among us.

Enter the bots

A quick search in GitHub reveals scripts developed to gain an advantage in booking one of these in-demand campsites.

There’s also paid services (like this one and that one) that offers to monitor the reservation website and alert you of cancellations.

Another quick search in your favorite search engine reveals articles and forum chatter about the dastardly nature of these bots, with discussion about the unfairness of it all. People are frustrated with the reservations processes going back several years.

Let’s dig deeper into what happens when reserving a campsite.

Breaking down a campsite reservation

Go to Recreation.gov in your browser. Open your browser’s DevTools and head over to the Network tab to see all of the network calls sent to the servers as you browse the site.

Checking availability

On the website, select your preferred campground, and then hit View by Availability. In DevTools under Network, you’ll see a request submitted to an endpoint called /availability. Right click on this request, and select “Copy as cURL” to copy it to your clipboard.

copy as cURL

We’ve previously used Postman to reverse engineer an API. Let’s switch over to Postman now to inspect what’s happening and modify what we send to Recreation.gov’s servers.

Paste the cURL from your clipboard to import it into Postman as raw text.

import cURL as raw text

This GET request does not require authorization, and retrieves the availability of all campsites for your selected campground. We can further inspect the headers and other components of this request.

Hit Send, and inspect the response.

inspect elements like request headers and response body

This shows us what’s happening in the background as we browse the website.

Booking a reservation

Back on the website, click “Book Now” to temporarily call dibs on a campsite for a specific date. Once you do this, you’ll have 15 minutes to complete the reservation before that spot is released back into inventory.

In DevTools under Network, you’ll see a request submitted to an endpoint called /multi. Import the request into Postman like we did before.

Under Headers, we see this POST request requires a Bearer token as an authorization header. Under Body, we see a JSON object with our reservation information.

Hit Send. The Recreation.gov servers already received a request submitted from the browser, and now we’re trying to submit the exact same request from the Postman client.

Well, that’s not going to work. But we understand a little more about what the Recreation.gov servers are expecting from the client, so we can begin building our bot.

Build your own bot

If you’re technically savvy and can write a bit of code, you can build your own bot with some googling and ingenuity. Really, there’s a few ways to get this done.

As you write your own bot, or use someone else’s, here’s some things to keep in mind.

Reuse and recycle

There’s several public solutions available as starters for various parts of the booking process. For example, you may find an app to intercept web requests and allow you to modify the payload before submitting a reservation. You can also choose to script any or all aspects of the reservation process.

Customize your criteria

Your strategy is completely up to you and your preference of campsites, dates, and other criteria. For example, someone may only be available for one week in the month of May while someone else may be flexible on dates but only want to stay in the Upper Pines camping area.

Speed is of the essence

Automation does not imply speed. You can automate a task to accomplish something very slowly. Optimize your program to run in an efficient manner allowing you to compete against other bots. For example, limiting your search to a few campsites takes less time than searching all the campsites in the campground.

complete your reservation within the 15 minute window

Is this fair?

It’s not illegal. But legal standards are not the same as ethical standards, which are established by societal norms.

What is fair

Recreation.gov promotes the programmatic use of their data via a public API. While it provides a lot of information, you can’t see campsite availability or book a reservation. Their website also uses an open JSON API to display information like availability, so that your program can access the same information that a human sees while browsing the website.

What is not fair

If you’re planning on reselling your camping spot, this is prohibited by most state and national parks. However, prosecutors typically go after folks who are commercially profiting or harming the website.

For just booking your own reservations, I couldn’t find anything on the current Recreation.gov website that explicitly prohibits the use of bots. However, I came across a number of comments online expressing frustration toward these bots. People think using a bot is “wrong”, “dishonest”, and “unfair”. Some comments go further, piling on a disgust of computers, technology, and tech workers.

Bots are simply programs created by humans. They can be helpful and automate a lot of tedious tasks. They can also be a nuisance and used for nefarious purposes. What they ultimately do, is up to the human writing the program.

With great power, comes great responsibility

-Uncle Ben

Final thoughts

It’s an interesting discussion about ethics, but I just want to go camping. It would be lovely if the National Park Service came up with a fair process that was also sustainable for our public parks, and everyone could camp freely without writing a bot.

For those who want to book a campsite in the Yosemite valley, the conversation about fairness focuses on how public access to natural resources has been co-opted by the technologically literate. Indeed the digital divide still exists even though more people now have access to the internet and technical resources.

I’m privileged because I know how to use technology to my advantage. Like most people, I rely on free resources and public communities to improve my technological literacy. If you want to learn how to do something, you can do it. The circle of life involves consuming, and then sharing, technical knowledge in forums and articles like this one.

--

--