To secure an API, you can use HTTPS to encrypt data, use OAuth or OpenID Connect for user authentication, validate user input to prevent injection attacks, implement rate limiting to prevent DDoS attacks, and log API activity to detect potential security breaches.