How to let the Opencart APIs work for all IP addresses?

Opencart checks the IP address to allow the API calls, but sometimes you need to let all IP addresses do the API calls, for example, while testing the API. To allow all IP addresses to comment following the line of code at catalog/controller/api/account/login.php

//$json[‘error’] = sprintf($this->language->get(‘error_ip’), $this->request->server[‘REMOTE_ADDR’]);

if ($api_info) {
	// Check if IP is allowed
	$ip_data = [];

	$results = $this->model_account_api->getIps($api_info['api_id']);

	foreach ($results as $result) {
		$ip_data[] = trim($result['ip']);

	if (!in_array($this->request->server['REMOTE_ADDR'], $ip_data)) {
		//$json['error'] = sprintf($this->language->get('error_ip'), $this->request->server['REMOTE_ADDR']);
} else {
	$json['error'] = $this->language->get('error_key');

To learn more about Opencart API following posts help more:

Previous articleHow to develop an Opencart 4.0.1 custom theme? OpenCart 4 theme development tutorial
Next articleDesigning for mobile: 5 best practices for UI designers


Please enter your comment!
Please enter your name here