Error Code Reference
Code Constant Message Description 0OK OK Success 4000ERROR_CODE_INVALID_UNIT Invalid unit Invalid ad unit ID 4001ERROR_CODE_AD_INACTIVE Ad inactive No active ad campaigns 4002ERROR_CODE_AD_NO_FILL No fill No matching ads available 4003ERROR_CODE_INVALID_PARAMS Invalid params Invalid parameters
Detailed Error Descriptions
ERROR_CODE_INVALID_UNIT (4000)
Cause : Requested with a non-existent or deactivated ad unit ID.
Solutions :
Verify the ad unit ID is correct in the console
Check that the ad unit is in active status
Ensure no whitespace or special characters were included when copying
{
"code" : 4000 ,
"msg" : "Invalid unit" ,
"result" : null
}
ERROR_CODE_AD_INACTIVE (4001)
Cause : No active ad campaigns for the specified ad unit.
Solutions :
Verify campaigns are running in the console
Check campaign schedule (start/end dates)
Ensure campaign budget is not exhausted
{
"code" : 4001 ,
"msg" : "Ad inactive" ,
"result" : null
}
ERROR_CODE_AD_NO_FILL (4002)
Cause : Unable to find ads matching the targeting criteria.
Solutions :
Check if targeting settings are too restrictive
Implement retry logic (exponential backoff recommended)
Prepare fallback content
{
"code" : 4002 ,
"msg" : "No fill" ,
"result" : null
}
Retry Implementation Example :
async function requestAdWithRetry ( params , maxRetries = 3 ) {
for ( let i = 0 ; i < maxRetries ; i ++ ) {
try {
const response = await axios . get ( 'https://api-v2.adrop.io/request' , {
params ,
headers: { 'Authorization' : 'YOUR_APP_KEY' }
});
if ( response . data . code === 0 ) {
return response . data . result ;
}
if ( response . data . code === 4002 ) {
// No fill - retry
await new Promise ( r => setTimeout ( r , Math . pow ( 2 , i ) * 1000 ));
continue ;
}
// Return immediately for other errors
throw new Error ( response . data . msg );
} catch ( error ) {
if ( i === maxRetries - 1 ) throw error ;
}
}
return null ; // Show fallback content
}
ERROR_CODE_INVALID_PARAMS (4003)
Cause : Request parameters are malformed.
Solutions :
Verify required parameter (unit) is included
Check that parameter values are in correct format
Ensure no typos in parameter names
{
"code" : 4003 ,
"msg" : "Invalid params" ,
"result" : null
}
Parameter Checklist :
Parameter Required Valid Examples unitRequired AD_UNIT_123pfRecommended android, ios, weblclRecommended ko_KR, en_USthemeOptional light, dark
Error Handling Best Practices
1. Handle Errors Based on Code
function handleAdResponse ( response ) {
switch ( response . code ) {
case 0 :
// Success - render ad
renderAd ( response . result );
break ;
case 4000 :
// Unit ID error - log it
console . error ( 'Invalid unit ID' );
break ;
case 4001 :
case 4002 :
// No ads - show fallback content
showFallbackContent ();
break ;
case 4003 :
// Parameter error - alert developers
console . error ( 'Invalid parameters:' , response . msg );
break ;
default :
// Unknown error
console . error ( 'Unknown error:' , response . code , response . msg );
}
}
2. Prepare Fallback Content
function showFallbackContent () {
const container = document . getElementById ( 'ad-container' );
container . innerHTML = `
<div class="fallback-content">
<img src="/images/house-ad.jpg" alt="House Ad" />
</div>
` ;
}
3. Monitoring and Logging
function logAdError ( code , message , params ) {
// Monitor error rates
analytics . track ( 'ad_error' , {
error_code: code ,
error_message: message ,
unit_id: params . unit ,
timestamp: new Date (). toISOString ()
});
}
HTTP Status Codes
The REST API also returns standard HTTP status codes.
HTTP Status Description 200Request successful (check response body for error code) 401Authentication failed (verify App Key) 500Internal server error
Always check the code value in the response body even for HTTP 200. Business logic errors are included in the response body.
REST API Overview Basic API usage
Targeting Settings Configure targeting parameters