I need like,

http://www.trackcourier.in/

The customer chooses selected courier service and enters tracking id then clicks its redirect to the appropriate courier service website.

eg: If tracking id 12345 the redirect link should be https://www.fedex.com/apps/fedextrack/index.html?tracknumbers=12345&cntry_code=in

How to do for India courier services?

Dani AI

Generated

asked for a simple redirect flow (select courier + tracking ID → send visitor to that carrier’s tracking page). and correctly pointed out deeper options (carrier APIs / aggregators) for showing live status. For a lightweight solution that only needs a redirect, a whitelist + URL‑template approach is simpler to implement and maintain.

Minimal PHP redirector (config-driven, safe whitelist):

<?php
// carrier => URL template (include {TRACKING} placeholder)
$carriers = [
  'indipost'  => 'https://www.indiapost.gov.in/...search={TRACKING}',
  'bluedart'  => 'https://www.bluedart.com/track?awb={TRACKING}',
  'delhivery' => 'https://track.delhivery.com/?waybill={TRACKING}',
  // keep this list in a config file or DB and offer an admin edit UI
];

$carrier  = strtolower(trim($_REQUEST['carrier'] ?? ''));
$tracking = trim($_REQUEST['tracking'] ?? '');

if ($carrier === '' || $tracking === '' || !isset($carriers[$carrier])) {
  http_response_code(400); echo 'Invalid carrier or tracking.'; exit;
}

// basic validation: allow only expected chars in tracking numbers
if (!preg_match('/^[A-Za-z0-9\-]+$/', $tracking)) {
  http_response_code(400); echo 'Invalid tracking format.'; exit;
}

$target = str_replace('{TRACKING}', urlencode($tracking), $carriers[$carrier]);

// Use 302 for simple GET redirects; use 303 after POST submissions
header('Location: ' . $target, true, 302);
exit;
?>

Practical notes and gaps the thread didn’t fully cover:

  • Keep templates in a config or DB so admins can update URLs when carriers change.
  • Avoid open‑redirects by never redirecting to arbitrary user input — only to templates from your whitelist.
  • Add a small carrier‑detection fallback (regex heuristics) to preselect the carrier; for example India Post numbers commonly match /^[A-Z]{2}\d{9}[A-Z]{2}$/i, while many AWBs are numeric (/^\d{8,16}$/). If detection fails, show the carrier dropdown.
  • If the site needs tracking details (status, timestamps), use carrier APIs or an aggregator and cache results to respect rate limits and improve performance.
  • Log failed lookups and keep a test suite that validates templates after any carrier change.

This pattern covers the typical "redirect-only" use case and leaves the option to add API integrations later if richer data is required.

Recommended Answers

All 3 Replies

The last time a developer needed Fedex tracking they used their API. And if they didn't understand the API then they contacted Fedex.

However I'm running into developers that either don't write code (?!) or don't want to work with the API or its owner. Seems today's developers can be one odd lot.

yes you can use it similarly like https://anycouriertracking.com/st-courier-tracking/ are doing. They are basically creating apis + python for tracking the couriers. Hopefully it helps. You can also get already built api's online. afterdispatch is a good example for it. In addition to this there are a lot of many other websites. However you can face issues if the courier companies arent allowing api's to connect to them and fetch data. In that case you will be hanging at point blank.

The last time a developer needed Fedex tracking they used their API. And if they didn't understand the API then they contacted Fedex.

The OP was specifically looking for something similar to the FedEx API but for courier services that operate throughout India. From what I can tell, FedEx operates in India as an international-only courier service (e.g. shipping to/from India to overseas).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.