Mocklets
  • Getting Started
  • Working with Collections
    • Create Collection
    • Invite Members
  • Managing Mock Apis
    • Dynamic Responses
    • URL Regex Matching
    • Use API as Proxy
    • Randomised Responses
    • Response Delay
    • Using Query Params
    • API Comments
  • Manage your files
  • Open API Specifications 3.x
  • Integration with external editors
  • Response Headers
  • Monitor Request Logs
  • Secure your mock APIs
  • Important Links
    • Home
    • Dashboard
    • Privacy Policy
    • Terms of Use
Powered by GitBook
On this page

Was this helpful?

  1. Managing Mock Apis

URL Regex Matching

PreviousDynamic ResponsesNextUse API as Proxy

Last updated 5 years ago

Was this helpful?

Mocklets work on matching your API request URL, but in some cases exact matching on the request URL alone is not specific enough. For instance, you may want to simulate an API /api/user/<user_id>/profile, where some portion of the URL string is variable. We cannot expect one to create multiple APIs with all the possible matching URL. This is can be achieved by adding RegEx sequence in your API request URL.

To enable RegEx matching for your API, just replace the variable section of the URL with {...}. Mocklets system will auto detect the RegEx placeholder and validate it against the incoming request URL.

For example in the above screenshot, the mock API provided with path as https://api.mocklets.com/mock67795/user/{...}/profile is a valid candidate for requests like https://api.mocklets.com/mock67795/user/123456/profileorhttps://api.mocklets.com/mock67795/user/c81d4e2e-bcf2-11e6-869b-7df9253/profile.

If you want to add any regex element in the API path, use {...} in its place and later while making request to that API, replace {...} with actual text.

In order to be valid regex match, the actual text should only be comprised of the following. Alphabets a-z A-Z Numbers 0-9 Symbols _ - = + . @

You can also verify your text for regex validation here .

https://mocklets.com/regex