HTTP request equivalent of `curl --user` parameter?
<p>I am retrieving events data from <a href="https://documentation.mailgun.com/quickstart-events.html" rel="noreferrer">the Mailgun API</a>. I am able to run this on the command line and get data back:</p>

<pre><code>curl -s --user 'api:key-xxxx' https://api.mailgun.net/v3/mydomain.net/events
</code></pre>

<p>Now I want to script this with Python and requests. I know that it is possible <a href="https://documentation.mailgun.com/api-intro.html#authentication" rel="noreferrer">to make a request using Basic-Auth to get the data via a URL</a>. However, Mailgun says that API keys should be treated like a password, so I'd prefer not to expose API keys directly in the URLs if possible.</p>

<p>Is there any way I can do the equivalent of <code>curl --user</code> in requests, to supply the parameter but without exposing it in the URL?</p>

<p>Alternatively, would it be better to try to use <code>curl</code> directly inside Python?</p>