linkedin-profile-validator

Crates.iolinkedin-profile-validator
lib.rslinkedin-profile-validator
version0.1.0
created_at2025-07-30 12:06:13.458028+00
updated_at2025-07-30 12:06:13.458028+00
descriptionA Rust library to validate LinkedIn profile URLs by checking format and profile existence
homepagehttps://github.com/RustSandbox/linkedin_profile_validator
repositoryhttps://github.com/RustSandbox/linkedin_profile_validator
max_upload_size
id1773412
size100,875
Hamze GHALEBI (hghalebi)

documentation

https://docs.rs/linkedin-profile-validator

README

LinkedIn Profile Validator

Crates.io Documentation CI License: MIT License: Apache 2.0

A robust Rust library to validate LinkedIn profile URLs, checking both format and profile existence.

Features

  • Format validation - Check if a URL follows LinkedIn profile URL pattern
  • Existence validation - Verify the profile actually exists (doesn't redirect to 404)
  • Blocking and async APIs - Choose based on your application needs
  • Detailed error types - Know exactly why validation failed
  • Fast and reliable - Built with reqwest and proper error handling

Installation

Add this to your Cargo.toml:

[dependencies]
linkedin-profile-validator = "0.1.0"

Or use cargo add:

cargo add linkedin-profile-validator

Usage

Quick format check (no network calls)

use linkedin_profile_validator::is_valid_linkedin_profile_format;

fn main() {
    let url = "https://www.linkedin.com/in/johndoe";
    if is_valid_linkedin_profile_format(url) {
        println!("Valid LinkedIn profile URL format!");
    }
}

Full validation with network check (blocking)

use linkedin_profile_validator::LinkedInValidator;

fn main() {
    let validator = LinkedInValidator::new();
    let url = "https://www.linkedin.com/in/johndoe";
    
    match validator.is_valid_linkedin_profile_url(url) {
        Ok(_) => println!("Profile exists!"),
        Err(e) => println!("Invalid: {}", e),
    }
}

Async validation

use linkedin_profile_validator::validate_linkedin_url_async;

#[tokio::main]
async fn main() {
    let url = "https://www.linkedin.com/in/johndoe";
    
    match validate_linkedin_url_async(url).await {
        Ok(_) => println!("Profile exists!"),
        Err(e) => println!("Invalid: {}", e),
    }
}

Error Types

The library provides detailed error information:

  • InvalidUrl - The URL format is invalid
  • NotLinkedInUrl - The URL is not from linkedin.com domain
  • NotProfileUrl - The URL is not a profile URL (e.g., it's a company page)
  • ProfileNotFound - The profile doesn't exist (redirects to 404)
  • NetworkError - Network request failed
  • AuthenticationRequired - LinkedIn requires authentication to verify the profile

Important Notes

LinkedIn's Anti-Bot Protection

LinkedIn actively prevents automated profile checking and may:

  • Return status code 999 for suspected bot traffic
  • Redirect to an authentication wall
  • Rate limit requests

When the library encounters these protections, it returns an AuthenticationRequired error. This doesn't necessarily mean the profile doesn't exist, just that LinkedIn is preventing automated verification.

Rate Limiting

To avoid being blocked by LinkedIn:

  • Don't make too many requests in a short time period
  • Consider adding delays between requests in your application
  • Use the format validation (is_valid_linkedin_profile_format) when you don't need to verify existence

Valid URL Patterns

Valid LinkedIn profile URLs follow this pattern:

  • https://www.linkedin.com/in/username
  • https://linkedin.com/in/username
  • https://www.linkedin.com/in/user-name-123/

Development

# Run tests
cargo test

# Check formatting and linting
cargo fmt -- --check
cargo clippy -- -D warnings

# Run the example
cargo run --example basic

# Build documentation
cargo doc --open

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate. See CONTRIBUTING.md for more details.

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 0

cargo fmt